How to get PlayerId after user subscribes in OneSingal


#1

I am developing an app using ionic2 and I am using OneSingal to send notification and I want to retrieve the player id so I can store in my DB so my question is how to can I retrieve the OneSignal users’ unique player after a user subscribes?


#2

it’s a bit late i guess, but as it may help others trying to do so i post this answer hoping it might come handy :slight_smile:
after your endInit() you can get the player id and the device token from this built-in function

    constructor(private oneSignal: OneSignal, . . . ){}
    .
    .
    this.oneSignal.endInit();
    this.oneSignal.getIds().then((id) => {
      console.log(id);
      let alert = this.alertCtrl.create({
          title: 'the onesignal ids object',
          message: JSON.stringify(id),
          buttons: [{
            text: 'Ok',
            role: 'ok'
          }]
        });
        alert.present();
    });

#3

This worked for me :slight_smile: Thanks a lot :smile:


#5

Thanks a lot. It’s worked fine for me.:smile: