0

I'm using OneSignal in my React Native app, and an endpoint in the API I'm using is asking for a OneSignal push token. The token they're asking for seems to have the same format as the app ID that was generated for my app on OneSignal. Are they the same thing?

gkeenley
  • 6,088
  • 8
  • 54
  • 129

1 Answers1

0

No they are not, The onesignal appId is the identifier for the app There are several types of keys in onesignal

  1. The rest API key for onesignal : this can be used to call the onesignal api to send notifications (Can be found at Settings> Keys & Ids)
  2. Player Id : An identifier for a specific user in your application, this can be used to send notification to a specific user in your app
  3. Push token : This is something similar to Player Id and can be retrieved the same way as player id

The below code can be used to get the playerid and the pushtoken

componentWillMount() {
   OneSignal.init("YOUR_ONESIGNAL_APPID");
   OneSignal.addEventListener('ids', this.onIds);
}

componentWillUnmount() {
    OneSignal.removeEventListener('ids', this.onIds);
}

onIds(device) {
    console.log('Device info: ', device);
}

The device variable will have the playerId and the pushToken

More info can be found at the SDK Page

Guruparan Giritharan
  • 15,660
  • 4
  • 27
  • 50