首页 > 解决方案 > 将应用程序从 GCM 更新到 FCM 后,iOS 设备未收到推送通知

问题描述

我最近将我的应用程序从 GCM 更新到了 FCM,如果我安装了最新的应用程序而不更新现有的应用程序,它工作正常。如果我更新应用程序,则设备不会收到推送通知。根据服务器,它说推送已成功发送,但设备未收到推送通知。

服务器响应 服务器响应

观察:

  1. iOS:当我将应用程序从 GCM 更新到 FCM 时,我得到了一个新令牌。
  2. Android :如果我将应用程序从 GCM 更新到 FCM,令牌仍然保持不变。

在启动功能上更新应用程序后,我调用以下行,

[[UIApplication sharedApplication] registerForRemoteNotifications]; 
[FIRApp configure];
[self connectToFcm];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:)
                                             name:kFIRInstanceIDTokenRefreshNotification object:nil];

在上面的代码中,令牌刷新被触发并获得了一个新的 FCM 令牌。

- (void)tokenRefreshNotification:(NSNotification *)notification
{
    NSString *refreshedToken = [[FIRInstanceID instanceID] token];
    NSLog(@"InstanceID token: %@", refreshedToken);
   [FCMPlugin.fcmPlugin notifyOfTokenRefresh:refreshedToken];
   [self connectToFcm];
}

将应用程序从 GCM 更新到 FCM 时,是否需要设置任何标志以使其在 iOS 中工作?

注意:通过删除 instanceID,我得到了一个新令牌,使用该令牌,设备能够获得推送。

旧应用程序:使用 GCM 令牌 - 工作新应用程序:使用 FCM 令牌 - 工作更新应用程序:来自 GCM 令牌 - FCM 令牌 - 不工作

标签: ioscordovapush-notificationcordova-plugin-fcm

解决方案


推荐阅读