Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

OneSignal

The OneSignal item provides remote push notifications for iOS & Android over the OneSignal service. More...

Import Statement: import Felgo 4.0
Inherits:

PluginItem

Properties

Signals

Methods

Detailed Description

Push Notifications are a great way to keep users engaged and inform users about updates in your app.

Property Documentation

appId : string

Set this property to your OneSignal app id of your custom app, found in your OneSignal Account.


googleProjectNumber : string

Set this property to the Google Project number of your Google Cloud Messaging project. See OneSignal Account for more information.


logLevel : LogLevel

Set a custom log level for debugging output. Possible values are:

  • OneSignal.LogLevelNone
  • OneSignal.LogLevelFatal
  • OneSignal.LogLevelError
  • OneSignal.LogLevelWarn
  • OneSignal.LogLevelInfo
  • OneSignal.LogLevelDebug
  • OneSignal.LogLevelVerbose

The default log level is OneSignal.LogLevelNone.


notificationWhenActive : bool

This property defines how your app handles notifications on Android while your app is running in the foreground. The property cannot change at runtime, it must be set when the OneSignal item is created.

Set this property to true to queue a new notification in the Android notification bar. The notification is delivered as soon as the user taps the notification (notificationReceived is called).

Set this property to false to instantly deliver the notification, triggering notificationReceived.

This property is unused on iOS.

The default value for this property is false.


registrationId : string

Read-only propertyof the platform-specific registration id at Apple or Google. You can use this ID to send push notifications to specific devices but it's recommended to use the userId oder custom tags for that.

See also userId.


[since Felgo 3.3.0] shareLocationEnabled : bool

This property defines if your app shares the device location with OneSignal.

Set this property to true to send the device's location to OneSignal when a notification is received. Set it to false to hide the location from the OneSignal backend.

When this property is first set to true, it needs device location authorization. The user can allow or deny the usage of the device's location with a dialog prompt.

Note: On iOS, add one or more location authorization descriptions to your ios/Project-Info.plist. Examples:

 <key>NSLocationUsageDescription</key>
 <string>Use location (iOS 7+)</string>
 <key>NSLocationWhenInUseUsageDescription</key>
 <string>Use location when app is in foreground</string>
 <key>NSLocationAlwaysUsageDescription</key>
 <string>Use location when app is in background</string>
 <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
 <string>Use location always</string>

Note: On Android, add one or both location permissions to your android/AndroidManifest.xml. Examples:

 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

The default value for this property is false.

This property was introduced in Felgo 3.3.0.


userId : string

Read-only property, providing the individual OneSignal user id after registering for push notifications. You can use this id to send push notifications to specific user devices.


Signal Documentation

notificationReceived(string message, variant additionalData, string actionId, variant actionButtons, bool isActive)

Emitted after a notification was received, either when the app is in the foreground or when a user opens the app by tapping on a notification in the platform-specific notification center.

The message parameter contains the push notification's message.

The additionalData parameter is a map containing the payload of the received notification, which you can use for further actions (see OneSignal Plugin#Advanced Usages).

The actionId paramter contains the pressed action button's ID. If no action button was pressed, it contains an empty string.

The actionButtons parameter is a list containing information about the notification's action buttons. Each entry in the list has the fields icon, id and text. If the notification has no action buttons, it contains en empty list.

The isActive parameter is true if the app was in the foreground when the notification was received, otherwise false.

Note: The corresponding handler is onNotificationReceived.


tagsReceived(variant tags)

Emitted after the user's currently set tags are received after requesting them with requestTags().

The tags parameter is a map containg the currently set user tags.

Note: The corresponding handler is onTagsReceived.

See also requestTags().


Method Documentation

[since Felgo 2.14.1] void clearNotifications()

Call this method to remove all OneSignal notifications from the phone's notification area.

This method was introduced in Felgo 2.14.1.


void deleteTag(string key)

Call this method to delete a tag that was previously set on a user with sendTag() or sendTags(). Use deleteTags() if you need to delete more than one.

See also deleteTags().


void deleteTags(variant keys)

Call this method to delete multiple tags that were previously set on a user with sendTag() or sendTags(). Use deleteTag() if you need to delete only a single one.

See also deleteTag().


void requestTags()

Call this method to request the currently set tags for the user. The method is asynchronous and the tagsReceived signal handler is emitted as soon as all tags are loaded from the OneSignal backend.

See also tagsReceived.


void sendTag(string key, string value)

Call this method to tag a user with a specific key/value pair. You can use this tag later on to send targeted push notifications or create segments on http://onesignal.com.

To set a custom userId tag for example, call this function like this:

 sendTag("userId", "<your-user-id-string>")

If you want to send more than one tag at a time you can also use sendTags().

See also sendTags.


void sendTags(variant tags)

Call this method to tag a user with multiple key/value pairs. You can use these tags later on to send targeted push notifications or create segments on http://onesignal.com.

To set a custom userId tag and the country of your user for example, call this function like this:

 var tagsMap = {}
 tagsMap["userId"] = "<your-user-id-string>"
 tagsMap["userCountry"] = "<your-user-country>"
 sendTags(tagsMap)

If you want to send only a single tag at a time you can also use sendTag().

See also sendTag.


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded