我在我的 React Native 应用程序中使用 OneSignal,而我正在使用的 API 中的一个端点正在请求 OneSignal 推送令牌。他们要求的令牌似乎与app ID
我在 OneSignal 上为我的应用程序生成的格式相同。它们是一样的吗?
问问题
802 次
1 回答
0
No they are not, The onesignal appId is the identifier for the app There are several types of keys in onesignal
- 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)
- 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
- 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
于 2020-04-24T12:11:09.850 回答