I am using onesignal plugin for an app that I am developing in Ionic 2, the plugin is working. The messages sent from OneSignal are showing in the app but I have a problem when I try to get the player unique id:
This is the code that I use for showing messages, this code works:
let notificationOpenedCallback = function(jsonData) {
let alert =alertCtrl.create({
title: jsonData.notification.payload.title,
subTitle: jsonData.notification.payload.body,
buttons: ['OK']
});
alert.present();
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
};
window["plugins"].OneSignal
.startInit("05d411f4-45da-4101-92a5-4a60e5c9fd03", "49543248748")
.handleNotificationOpened(notificationOpenedCallback)
.endInit();
and this code is for get Ids:
window["plugins"].OneSignal
.startInit("05d411f4-45da-4101-92a5-4a60e5c9fd03", "49543248748")
.endInit();
window["plugins"].OneSignal.getIds(function(ids){
firebase.database().ref('usuarios/'+ this.usuarioId).update({
idOnesignal: ids.userId
})
this code just does not run