objective-c - Firebase FCM 实例 ID 为零(在真实设备上运行快速启动应用程序)

标签 objective-c iphone xcode firebase-cloud-messaging

在我的 iPhone 上运行 FCM 演示应用程序不起作用 - Firebase ID 为nil

重现步骤:

  1. pod try Firebase,然后运行 ​​10: quickstart-ios/messaging/FCM.xcodeproj
  2. 将我的 GoogleService-Info.plist 文件复制到项目中
  3. 在 iPhone 5s (iOS 9.3.2) 上运行应用
  4. 接受请求允许发送通知的对话框
  5. 点击按钮
  6. 实例 ID 标记为nil

我的 Mac 有适当的证书来开发和部署应用程序:

  1. 我同时拥有 iOS 分发和 iOS 开发配置 配置文件,使用“自动”设置选择。
  2. 我安装了 iOS 分发证书和 iOS 开发证书,并使用“自动:iPhone 开发人员”选项进行了代码签名
  3. 我安装了“生产”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
  • 下启用Push Notifications
  • 避免调用 unregisterForRemoteNotifications。此调用后,您无法再注册设备以推送通知。
  • 在您的 info.plist 文件中将 FirebaseAppDelegateProxyEnabled 设置为 NO。我认为他们的方法调配存在错误。
  • didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken 方法中调用 [[FIRMessaging messaging] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeUnknown]

关于objective-c - Firebase FCM 实例 ID 为零(在真实设备上运行快速启动应用程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38030081/

相关文章:

ios - Sprite Kit,抑制速度较慢的iPhone的质量

ios - UIBezierPath 撤消绘图重绘 UIImageView 的图像

iphone - 从 NSString 获取 NSDate

ios - 使用 UIActivityViewController 将 PNG 图像共享到 Facebook Messenger 总是失败

ios - NSFetchRequest 返回的数组计数错误

ios - 阻止 UIScrollView 滚动,如果滑动手势是在一个区域

iPhone音频播放: force through internal speaker?

ios - 在应用程序启动时, subview 在设备的不同初始方向上采用不同的帧大小

c++ - 使用 Makefile 构建时在 Xcode 中忽略的断点

Swift:如何像 iOS 13 的 Book 应用程序一样为 PDF 实现标记(注释)?