![](/img/trans.png)
[英]React Native: Null is not an object - Push notification (OneSignal)
[英]react native onesignal android push token is null
我正在使用react-native-onesignal並且推送令牌為null。
async componentDidMount() {
const { currentState } = AppState
OneSignal.init(ONESIGNAL_APP_ID)
OneSignal.configure();
OneSignal.registerForPushNotifications();
OneSignal.addEventListener('received', this.onReceived)
OneSignal.addEventListener('opened', this.onOpened)
OneSignal.addEventListener('ids', this.onIds)
}
onReceived = (notification) => {
console.log("Notification received: ", notification)
}
onOpened = (openResult) => {
console.log('Message: ', openResult.notification.payload.body)
console.log('Data: ', openResult.notification.payload.additionalData)
console.log('isActive: ', openResult.notification.isAppInFocus)
console.log('openResult: ', openResult)
}
onIds = (device) => {
console.log('Device info: ', device)
}
您應使用onesignal帳戶中的應用程序ID替換ONESIGNAL_APP_ID(登錄到onesignal帳戶后,可以在“設置->鍵和ID”標簽中找到)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.