OneSignal Notifications¶
Non-Visible component| Category | Requires | Version |
|---|---|---|
| Social | API 21, Android 5.0 Lollipop | 1 |
Overview¶
A non-visible component for receiving and controlling push notifications sent remotely using OneSignal.
Permissions
- com.sonyericsson.home.permission.BROADCAST_BADGE
- com.htc.launcher.permission.READ_SETTINGS
- android.permission.FOREGROUND_SERVICE
- android.permission.RECEIVE_BOOT_COMPLETED
- com.huawei.android.launcher.permission.WRITE_SETTINGS
- me.everything.badger.permission.BADGE_COUNT_READ
- com.sec.android.provider.badge.permission.WRITE
- com.sec.android.provider.badge.permission.READ
- android.permission.ACCESS_NETWORK_STATE
- android.permission.WAKE_LOCK
- com.anddoes.launcher.permission.UPDATE_COUNT
- android.permission.POST_NOTIFICATIONS
- com.google.android.c2dm.permission.RECEIVE
- com.oppo.launcher.permission.WRITE_SETTINGS
- android.permission.READ_APP_BADGE
- %packageName%.permission.C2D_MESSAGE
- android.permission.VIBRATE
- com.huawei.android.launcher.permission.CHANGE_BADGE
- com.majeur.launcher.permission.UPDATE_BADGE
- com.sonymobile.home.permission.PROVIDER_INSERT_BADGE
- com.htc.launcher.permission.UPDATE_SHORTCUT
- android.permission.INTERNET
- com.huawei.android.launcher.permission.READ_SETTINGS
- me.everything.badger.permission.BADGE_COUNT_WRITE
- com.oppo.launcher.permission.READ_SETTINGS
Events¶
Error Occurred¶
Called when an error occurs.
| Params | |
|---|---|
| message | Text |
Notification Clicked¶
Called when the user clicks the notification.
| Params | |
|---|---|
| android Notification ID | Number |
| from Project Number | Text |
| group Key | Text |
| sent Time | Number |
| ttl | Number |
| notification ID | Text |
Notification Permission State Changed¶
Called when the user accepts or declines the permission prompt, or enables or disables notifications for your app in the device's app settings and then returns to your app.
| Params | |
|---|---|
| granted | Boolean |
Push Subscription State Changed¶
Called when subscription state changes. This can happen when: 1. The device receives a new push token from Google (FCM) or Apple (APNs). 2. OneSignal assigns a subscription ID. 3. The optedIn value changes (e.g. called "OptIn" or "OptOut"). 4. The user toggles push permission in system settings, then opens the app.
| Params | |
|---|---|
| subscription Id | Text |
| opted In | Boolean |
| token | Text |
Methods¶
Get Push Subscription ID¶
Returns: Text
Returns the current push subscription ID. May return null if called too early.
Get Push Subscription Token¶
Returns: Text
Returns the current push subscription token. May return null if called too early.
Has Opted In¶
Returns: Boolean
Returns true if the current push subscription status is subscribed, otherwise false. If the push token is valid but OptOut was called, this will return false.
Opt In¶
Does one of three actions: 1. If the Subscription has a valid push token, it sets the current push subscription status to subscribed. 2. If the Subscription does not have a valid push token, it displays the push permission prompt. 3. If the push permission prompt has been displayed more than the operating system's limit (twice Android), it displays the fallback prompt.
Opt Out¶
Sets the current push subscription status to unsubscribed (even if the user has a valid push token).
Remove All Notifications¶
Removes all OneSignal notifications.
Remove Grouped Notifications¶
Cancel all notifications in a specific group based on its group key.
| Params | |
|---|---|
| group Key | Text |
Remove Notification¶
Cancel a single notification based on its Android notification ID.
| Params | |
|---|---|
| android Notification ID | Number |
Request Notification Permission¶
Shows the native system prompt asking the user for push notification permission. If "fallbackToSettings" is true, the fallback prompt will be displayed if the user denied push permissions more than twice.
| Params | |
|---|---|
| fallback To Settings | Boolean |
Properties¶
Can Request Permission¶
Continuation Write - Blocks
Returns whether attempting to request permission will result in a prompt being displayed to the user. If false, the user has already denied permission and can either be shown the fallback prompt or no prompt at all.