Ionic 2 - OneSignal - Get player_id

3

I use OneSignal for push notifications in an ionic application 2. To send targeted notifications to specific users I need to recover the OneSignal player_id.

Does anyone have any idea how to retrieve this id from the platform?

    
asked by anonymous 01.11.2017 / 17:46

1 answer

1

I found how to recover the player_id from the OneSignal plugin, and it's actually quite simple. In app.component.ts, I added the code:

  window["plugins"].OneSignal.getIds(ids => {
    console.log("player_id: " + ids.userId);
  });

With this, I get the PLAYER ID of the user, allowing, for example, the sending of push notifications directed to the specific user.

    
07.11.2017 / 20:25