Ronald Abellano
Ronald Abellano

Reputation: 874

How to get player_id in Ionic OneSignal?

I have a use case that I only have to send a notification to a specific user when I updated the user data from a desktop application. So that's why I need to get player_id generated by OneSignal? But their documentation does not show everything.

Upvotes: 1

Views: 1200

Answers (1)

suresh bambhaniya
suresh bambhaniya

Reputation: 1687

You can use addsubscriptionobserver Ref: addSubscriptionObserver

this.oneSignal.addSubscriptionObserver().subscribe((state) => {
   if (!state.from.subscribed && state.to.subscribed) {
    console.log("Subscribed for OneSignal push notifications! :: ID "+state.to.userId);
   }
});

Upvotes: 4

Related Questions