Using OneSignal and I try to save the player id in a javascript variable, the API is unclear

I have a OneSignal account connected to a Cordova / iOS app. I need to store the player ID in my own database so that I can send push notifications to specific users when tasks arise or events occur.

I reviewed the API here: https://documentation.onesignal.com/reference#view-device but I don’t know how to call a JavaScript function to save the variable identifier. There is no such example.

Any help would be greatly appreciated.

+7
javascript ios cordova onesignal
source share
1 answer

I get it.

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'])); }); 
+11
source share

All Articles