Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using OneSignal and I'm trying to save player id to javascript variable, API unclear

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.

like image 988
user1840525 Avatar asked Mar 18 '16 17:03

user1840525


1 Answers

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']));
            });
like image 176
user1840525 Avatar answered Sep 23 '22 15:09

user1840525