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:

  1. 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.
  2. Create a new Segment on the OneSignal dashboard named test devices.

  3. Press "Add Filter" and select "User Tag" as the "Filter Type".
  4. Enter is_test equal to true.
    • The values you used in step 1.
  5. 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)

  1. Get the user's player_id with the getIdsAvailable 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.
  2. Send the userId from the getIdsAvailable callback if the pushToken is not null or blank to your server.
  3. Set include_player_ids to the userId on the PostNotification SDK method or on the create notification REST API call.
Share:
25,199
Axil
Author by

Axil

Updated on November 24, 2020

Comments

  • Axil
    Axil over 3 years

    I want onesignal to be able to send push notification to a specific device.

    1. How do I capture the device id of the device ?

    2. And what API do I use to push to that specific device ?

    Thanks.