<FIRMessaging/WARNING> FIRMessaging注册尚未准备好使用身份验证凭据

Sub*_*dal 14 objective-c ios firebase firebase-authentication firebase-cloud-messaging

我想将Firebase Cloud Messaging与我的应用程序集成,但是当我运行应用程序时,我遇到以下错误:

  1. <FIRMessaging/WARNING> FIRMessaging registration is not ready with auth credentials.

  2. Unable to connect to FCM. Error Domain=com.google.fcm Code=501 "(null)"

这是我的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
        // iOS 7.1 or earlier
        UIRemoteNotificationType allNotificationTypes =
        (UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge);
        [application registerForRemoteNotificationTypes:allNotificationTypes];
    } else {
        // iOS 8 or later
        // [END_EXCLUDE]
        UIUserNotificationType allNotificationTypes =
        (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
        UIUserNotificationSettings *settings =
        [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
    }

    [FIRApp configure];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:)                                             name:kFIRInstanceIDTokenRefreshNotification object:nil];

    return YES;
}
Run Code Online (Sandbox Code Playgroud)

gm_*_*gm_ 1

可能的答案是您尚未添加用于开发和生产的 Apple APS 证书。这些是在 iOS 上发送推送通知所必需的。您必须拥有付费 Apple 开发人员许可证才能生成这些证书。要生成这些证书,请打开此链接,然后转到证书,然后单击右上角的加号按钮以创建新证书。然后按照以下页面上的说明进行操作,直到从 Apple 下载签名证书。然后转到 firebase 控制台,然后转到您的项目。然后单击齿轮,然后单击项目设置。打开云消息传递,然后在底部上传您的开发和生产证书,并输入您在创建它们时使用的密码。希望这对您有所帮助,如果您有任何问题,请随时询问。