小智 28

使用Xcode8,修复方法是简单地启用功能中的Keychain Sharing

打开app.xcworkspace文件,选择Target> Capabilities> Enable'Keychain sharing'

  • 你能澄清为什么我们启用这个功能吗?我做了如上所述,但它仍然没有获得FCM令牌. (4认同)

Rac*_*wat 27

此问题的可能原因:

  1. 设备日期未设置为当前日期.
  2. 捆绑ID与您在GoogleService-Info中设置的捆绑ID不同.
  3. 在Firebase控制台上上载的.p12证书不正确.

  • "1.设备日期未设置为当前日期." 一个非常重要和有趣的观点.你救了我一些时间!谢谢!无论如何,如果设备日期未设置为当前日期,是否有人知道为什么它不起作用? (8认同)
  • 竖起大拇指**设备日期**! (3认同)

Phi*_*hil 11

确保:

  • 捆绑ID与您在GoogleService-Info中设置的捆绑ID相同
  • 代码签名参数(Target => Build Settings => Code signing)更正并与您在Firebase中设置的p12证书文件相匹配. 在此输入图像描述

此外,你必须遵循这些tutos:

并且不要忘记向用户请求权限只是在您的应用程序中添加(例如在AppDelegate文件中,或在其他ViewController中):

let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
let pushNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
application.registerUserNotificationSettings(pushNotificationSettings)
application.registerForRemoteNotifications()
Run Code Online (Sandbox Code Playgroud)

  • 它仍然有问题 (4认同)