OneSignal how to send Push to specific device - ionic
25,199
Here is a copy of OneSignal's guide on sending a notification to an individual device:
If you're looking to send notifications to only your test devices:
-
Tag your devices with a unique tag with
sendTag
.- Example:
OneSignal.sendTag("is_test", "true")
- For an exact example see OneSignal's API Reference for the SDK you're using.
- Example:
Create a new Segment on the OneSignal dashboard named test devices.
- Press "Add Filter" and select "User Tag" as the "Filter Type".
- Enter is_test equal to true.
- The values you used in step 1.
- When creating a new notification, remove "All" and add your test devices segment.
If you're looking to send notifications to a specific user device: (Can be used for User-to-User notifications)
- Get the user's
player_id
with thegetIdsAvailable
SDK method.- See OneSignal's API Reference for the SDK you're using for example code.
- For testing you can use the 'Player ID' shown on the user page on the dashboard.
- You can force kill your app and open it again to bring your device to the top of the list.
- Send the
userId
from thegetIdsAvailable
callback if the pushToken is not null or blank to your server. - Set
include_player_ids
to the userId on the PostNotification SDK method or on the create notification REST API call.
Author by
Axil
Updated on November 24, 2020Comments
-
Axil over 3 years
I want onesignal to be able to send push notification to a specific device.
How do I capture the device id of the device ?
And what API do I use to push to that specific device ?
Thanks.