按照如下文章进行 React Native 下 iOS 推送的开发,出现了一些文章中没谈论到的错误,特此记录解决方案。
使用Leancloud实现React Native App的消息推送(Push Notification)- iOS篇 - 半路出家老菜鸟 - SegmentFault 思否
‘React/RCTPushNotificationManager.h’ file not found #
参照 https://facebook.github.io/react-native/docs/linking-libraries-ios 中 Manual linking 的步骤进行手动库链接操作,其中尤其注意的是 Step 3,讲库文件依赖的头文件路径添加进头文件搜索路径。
添加的路径为 ${SRCROOT}/../node_modules/react-native/Libraries/PushNotificationIOS
‘React/RCTEventEmitter.h’ file not found #
这个错误实际是从 RCTPushNotification 库中报出来的,所以我们实际上应该对 RCTPushNotification 库的头文件搜索路径也要做添加工作。步骤与添加项目的头文件搜索路径基本一致,只不过这次选中的是 RCTPushNotification.scodeproj
Bundle Id / Topics 的一致性 #
以下各处均涉及 Bundle Id 和 Topics 的填写,需保持正确一致:
- Apple Developer 注册时的 Bundle Id
- leancloud 中新增 iOS 推送 Token Authentication 时,填入的 Topic 需要与 Apple Developer 的 Bundle Id 一致
- Xcode 打开 .wcworkspace 工程后,Genenal 标签页中的 Bundle Identifier 需要与 Apple Developer 的 Bundle Id 一致