Send Notification to specific user using onesignal

Akshay Vaghasiya picture Akshay Vaghasiya · Mar 10, 2017 · Viewed 8.1k times · Source

I'm using onesignal for first time in my project. I have to send notification to specific users (wherever user is logged in either on chrome or android device) on some events like whatsapp sends notification on mobile as well as website too and only if user is logged in. I have successfully sent notification to all users. After some R&D on OneSignal, I come to know that I have to send notifications to specific playerId for this purpose. But here are some my questions/doubts.

  • I think player Id is device id. If I'm right, what if current user logged out and another user gets logged in on same device. How can I come to know that I have not to send notification on this player Id as user is changed.
  • Will be there multiple playerIds for single user? One for chrome, one for iOS device, one for Android etc?
  • How I will get playerId of user to store in my database. Because I have to use server rest API to send notifications.

If anyone can explain the points and also describe work flow to store playerid (when and how) in my database, it will be appreciated.

Answer

Kishan picture Kishan · Apr 26, 2017

Just store playerIds into database with login activity. when they logout just fire a query related to remove playerIds from database.