undefined 不是一个对象 '_react2.PushNotificationIOS.FetchResult'

undefined is not an object '_react2.PushNotificationIOS.FetchResult'

我目前是 运行 ReactNative 版本 0.54.0。我搜索了互联网并按照所有说明设置 PushNotification(manual linking:将 RCTPushNotification.xcodeproj 添加到 xcode 并链接 libRCTPushNotification 等)

我将 facebook 中的代码复制到 xCode

中的 AppDelegate.m

我已经从 react 导入了 PushNotificationIOS,从 react-native-push-notification 导入了 PushNotification。

我将 PushNotification.configure() 代码复制到我的 app.js 文件中。我不断收到的错误是 onNotification 方法中的“undefined is not an object '_react2.PushNotificationIOS.FetchResult'”。

任何人都可以让我知道我做错了吗?

确保你有像这样的导入

进口{ 样式表, 看法, 推送通知IOS } 来自 'react-native';

而不是

进口{ 样式表, 看法 } 来自 'react-native'; 从 'react-native';

导入 {PushNotificationIOS}