我正在使用react-native-onesignal而我正在获取推送令牌为空。
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)
}