如何解决无法获取默认令牌错误?

在这里输入图像说明

在iPhone中安装后,我得到这个错误。

使用Xcode8,解决方法是简单地在Capabilities中启用Keychain Sharing

打开app.xcworkspace文件,selectTarget> Capabilities> Enable'Keychain sharing'

这个问题的可能原因是:

  1. 设备date未设置为当前date。
  2. Bundle ID与您在GoogleService-Info中设置的ID不相同。
  3. 在Firebase控制台上传的.p12证书不正确。

确保:

  • Bundle ID与您在GoogleService-Info中设置的ID相同
  • 代码签名参数(Target => Build Settings =>代码签名)将被更正,并与您在Firebase中设置的p12 cert文件相匹配。 在这里输入图像说明

另外,你必须遵循这些教程:

  • 通知: https //firebase.google.com/docs/notifications/ios/console-audience
  • configuration: https //firebase.google.com/docs/ios/setup

并且不要忘记询问用户的权限,只需在你的应用程序中添加(例如在AppDelegate文件或其他ViewController中):

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

我有同样的问题未能获取默认令牌错误域= com.firebase.iid代码= 501今天花了4个小时,终于有问题,这是我的iPhone时间是错误的(手动我设置差异时间进行testing)

所以一旦检查时间,你有请求firebase令牌。

确保您已将开发APN证书上传到Firebase。 转到您的项目的设置=>云消息选项卡。

已经卡住了一段时间,对我来说,我无法工作的原因是,我正在使用辅助的Firebase应用程序。 它看起来像一个bug。 作为解决方法,我必须在默认应用程序(AppDelegate.m) 之前初始化其他应用程序:

 //initialise the secondary app, for example: NSString *logFirebaseOptionFile = [[NSBundle mainBundle] pathForResource:@"GoogleService-LOG-Info" ofType:@"plist"]; FIROptions *firebaseOptions = [[FIROptions alloc] initWithContentsOfFile:logFirebaseOptionFile]; NSString *logAppName = @"mybands_logs"; [FIRApp configureWithName:logAppName options:firebaseOptions]; //then the default app for FCM to work [FIRApp configure]; 

处理此错误之前,您必须修复此行:

无法获取默认标记Error Domain = com.firebase.iid Code = 0“(null)”

这是解决这个问题的答案

那么,我也有这个问题。 无法使用其他post引入的解决scheme修复此问题。 您的客户端应用程序FCM SDK和FCM服务器之间的通信似乎出错了。

我的修复是我login到我的VPN(中国大陆不能使用谷歌服务,如果你不这样做)。 然后我可以得到firebase令牌。

此外,如果你没有得到令牌。 下一次尝试使用[[FIRInstanceID instanceID]标记]访问Firebase标记。 如果Firebase SDK仍然为零,则会尝试再次获取令牌,如果尝试成功,则会发布令牌刷新通知(kFIRInstanceIDTokenRefreshNotification)。