[OneSignal Plugin] How to get player id of device

Forge Component
Published on 2019-10-18 by OutSystems R&D
13 votes
Published on 2019-10-18 by OutSystems R&D

I want to be able to send notifications to individual users. I am indeed able to, if I log into the OneSignal dashboard and find the player id of a certain device, but how can I get the player id within the app using the plugin?

I tried the RegisterWithUser action but the instructions on this page are extremely vague. The action succeeds, but then what? Where does the user get registered? Where can I see it? The OneSignal dashboard still shows a player id but no user id. What is the exact process by which I can use this action to associate a device with a user?

I would really prefer to be able to get the player id within the app. It seems like it should be returned by the Register action.

Figured it out. Future readers, create a client action with an output parameter and the following JavaScript:

window.plugins.OneSignal.getIds(function(ids) {
  $parameters.yourOutputParameter = ids.userId;

This uses the OneSignal PhoneGap SDK as documented here


Hey, Mitchell,

Thanks for sharing! I'll pass on the feedback to the team about it, so they can weight if it should be included in the plugin (looks like it).

In the meantime, let me just point out that, according to the documentation, there's a chance that those values might be empty, so make sure you create your logic around it.

Thanks again, and best regards,

Carlos Simões


Have there been any updates on this? I am trying to get the player ID of my registered Device but the Javascript that Mitchell has provided does not seem to be executing on my device. I am trying to print the result in the logs or in an alert but it does not seem to be executing. 

Is there any reason the player_id of the registered Device is not available as an output parameter from the registration?

Update: I tried this without the Resolve() and I was able to get a response but it was null. Why would it be null?  Mitchell, were you able to successfully get the playerId? how so?

So it looks like there have been two new methods added. GetDeviceID and GetDeviceType.

Get DeviceID returns the "DeviceID" but this is not the same as the PlayerID, which is required for sending push notifications to an individual device. In fact, I cannot find this device ID anywhere in the all users of my OneSignal application. 

What is the "DeviceID" returned in the new method and how can it be mapped to the playerId?

In my case I used the DeviceID to send it as a Tag to Onesignal, and when I want to send a notification to an specific user I use the tag as filter and get the DeviceID for the condition.

How can I find the DeviceId and how can I register it with OneSignal??

Any inputs on this!!