8

I have a OneSignal account hooked up to a Cordova/iOS app. I need to save the player id in my own database so I can send push notifications to specific users when tasks are due or events are happening.

I've looked at the API here: https://documentation.onesignal.com/reference#view-device but I don't know how to call a JavaScript function to save the identifier to a variable. There is no example of this.

Any help would be much appreciated.

Gdeglin
  • 12,432
  • 5
  • 49
  • 65
user1840525
  • 201
  • 2
  • 6
  • why you need javasript to get playerIDs? while add device only it will return playerID, then store into database. then retrieve from your database. – 151291 Nov 28 '16 at 05:29

1 Answers1

12

I figured it out.

window.plugins.OneSignal.getIds(function(ids) {
                //document.getElementById("OneSignalUserID").innerHTML = "UserID: " + ids.userId;
                //document.getElementById("OneSignalPushToken").innerHTML = "PushToken: " + ids.pushToken;
                alert(JSON.stringify(ids['userId']));
            });
user1840525
  • 201
  • 2
  • 6