当我在下面添加此代码时,会出现通知警报但我收到以下错误:

ExceptionsManager.js:84 未处理的 JS 异常:TypeError:RN OneSignal.didSetNotification Opened Handler 不是函数

显然这一行:

OneSignal.addEventListener('opened', this.onOpened)

当我删除它时问题就消失了,谢谢你的帮助

constructor(props) {
super(props)
   OneSignal.init("my ID");
   OneSignal.addEventListener('received', this.onReceived);
   OneSignal.addEventListener('opened', this.onOpened);
   OneSignal.addEventListener('ids', this.onIds);
}
componentWillUnmount() {
  OneSignal.removeEventListener('received', this.onReceived);
  OneSignal.removeEventListener('opened', this.onOpened);
  OneSignal.removeEventListener('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);
}

在此输入图像描述