在我的 iPhone 上运行 FCM 演示应用程序不起作用 - Firebase ID 为nil。
重现步骤:
pod try Firebase
,然后运行 10: quickstart-ios/messaging/FCM.xcodeproj
- 将我的
GoogleService-Info.plist
文件复制到项目中 - 在 iPhone 5s (iOS 9.3.2) 上运行应用
- 接受请求允许发送通知的对话框
- 点击按钮
- 实例 ID 标记为nil
我的 Mac 有适当的证书来开发和部署应用程序:
- 我同时拥有 iOS 分发和 iOS 开发配置 配置文件,使用“自动”设置选择。
- 我安装了 iOS 分发证书和 iOS 开发证书,并使用“自动:iPhone 开发人员”选项进行了代码签名
- 我安装了“生产”SSL 证书:“Apple Push Notification 服务 SSL(沙盒和生产)”
我在日志中看到很多噪音,但最重要的错误是这个:
Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"
这是完整的控制台输出:
2016-06-25 16:15:08.339 FCM[7398:4128979] Configuring the default app.
2016-06-25 16:15:08.383 FCM[7398:] <FIRAnalytics/INFO> Firebase Analytics v.3200000 started
2016-06-25 16:15:08.396: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-06-25 16:15:08.397: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"
2016-06-25 16:15:08.403: <FIRMessaging/INFO> FIRMessaging library version 1.1.0
2016-06-25 16:15:08.413: <FIRMessaging/WARNING> FIRMessaging AppDelegate proxy enabled, will swizzle app delegate remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-06-25 16:15:08.443 FCM[7398:] <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
2016-06-25 16:15:08.508 FCM[7398:] <FIRAnalytics/INFO> Firebase Analytics enabled
2016-06-25 16:15:08.538: <FIRInstanceID/WARNING> APNS Environment in profile: development
2016-06-25 16:15:08.848 FCM[7398:4128979] Connected to FCM.
2016-06-25 16:15:08.893: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"
2016-06-25 16:15:22.311: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"
2016-06-25 16:15:36.774 FCM[7398:4128979] Unable to connect to FCM. Error Domain=com.google.fcm Code=2001 "(null)"
2016-06-25 16:15:40.552 FCM[7398:4128979] Subscribed to news topic
2016-06-25 16:15:43.100 FCM[7398:4128979] InstanceID token: (null)
2016-06-25 16:15:49.036: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"
2016-06-25 16:16:31.022: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"
2016-06-25 16:17:32.976: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"
2016-06-25 16:17:32.976: <FIRInstanceID/WARNING> Failed to retrieve the default GCM token after 5 retries
2016-06-25 16:19:10.662 FCM[7398:4128979] InstanceID token: (null)
2016-06-25 16:19:10.980: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"
2016-06-25 16:19:10.981: <FIRInstanceID/WARNING> Failed to retrieve the default GCM token after 5 retries
最佳答案
尝试将 Firebase/Core 更新到 v3.4.4,它为我修复了意外错误。否则,典型的修复是:
- 在应用的
Capabilities
下启用 - 避免调用
unregisterForRemoteNotifications
。此调用后,您无法再注册设备以推送通知。 - 在您的 info.plist 文件中将
FirebaseAppDelegateProxyEnabled
设置为NO
。我认为他们的方法调配存在错误。 - 在
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
方法中调用[[FIRMessaging messaging] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeUnknown]
Push Notifications
关于objective-c - Firebase FCM 实例 ID 为零(在真实设备上运行快速启动应用程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38030081/