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.
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']));
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With