Push Notifications - OneSignal
Last updated
Was this helpful?
Last updated
Was this helpful?
We are using Service to provide a Push Notification functionality.
Notification permissions authorized - get called when the user clicks Allow on permission alert.
Notification permissions denied - get called when the user clicks Decline on permission alert.
Notification permissions status updated - get called when permission status was updated because of the user's action.
Permission Status - Yes or No.
Request the user's push notification permission - displays a systems popup with your Notification Permissions Text
Open Settings - If yes and user's previously denied notification permission. A native alert will be shown with the option to open the app settings and turn on permission.
Get the user's OneSignal PlayerId - Reload the user's OneSignal PlayerId
Get the user's push notification permission status
Actions:
OneSignal - PlayerIds - Send Push - Add a field to User's object to store Player Id
All parameters in these actions are pretty the same. The difference is only in the Data Source section.
Title
Subtitle [iOS]
Message
Redirect Url - The url that will be opened if user's click on push (Optional)
or
Data Source:
OneSignal - PlayerIds - Send Push action
List Type
List
Player ID field
OneSignal - Segments - Send Push action
Included - provide here a list of segments (separated by comma) that needs to be included in your push sending action
Excluded - provide here a list of segments (separated by comma) that needs to be excluded from your push sending action
The value should be like this: Active Users, Inactive Users
iOS Sound - set "natively.wav" if you wanna to use custom sound
Request Push Notification permission whenever you need it.
The OneSignal status is updated during app initialization. As a result, any changes to the permission status will take effect on the second app launch, after the user has granted or denied permission.
Save PlayerID to your user model
Send Push Notification to PlayerID you need (Backend workflow is recommended)
Send Push examples:
How to set up?
call requestPermissionIOS (required for both iOS & Android).
Save PlayerId somewhere (for example, save it in the user's playerId property).
There are 2 options:
Go to OneSignal App -> Settings -> Messaging
Scroll down to Android Notification Channels ->Click "Add Channel"
Scroll Down to "Sound" -> Add "natively" + Set Importance to Urgent or High
Copy Channel ID
Paste where you use it (Plugin or OneSignal API) + IMPORTANT: reinstall your Android app
Request the user's notification permission. You can do that in any necessary place. For example: show a popup that explains to the user's why your app needs it (so, it can be a better experience when just displaying a system popup)
Identify a user. By using player id.
On initialization, the element will try to get and the current notification permission status. (No need to call it on the Page Is Load event)
OneSignal Player Id updated - get called when was updated.
OneSignal PlayerId - 's text value.
OneSignal - Segments - Send Push - Use this if you need
Template ID - Check out OneSignal for more details
Android Channel Id -
Make sure you've your app and OneSignal for Push Notifications.
call getOneSignalId (will return ).
Send it with Natively SDK from your website (Which might be useful if running the app in a ):
2. Other provided by OneSignal (NodeJS SDK, WebAPI, etc.)
More information about OneSignal you can read in their .
Natively sendPushNotification method doesn't support custom notification sound. Please use OneSignal . Use and (ios_sound with "natively.wav" value)
Check a player_id value on each login (It can be )