ios - 将应用程序从 GCM 更新到 FCM 后,iOS 设备未收到推送通知
问题描述
我最近将我的应用程序从 GCM 更新到了 FCM,如果我安装了最新的应用程序而不更新现有的应用程序,它工作正常。如果我更新应用程序,则设备不会收到推送通知。根据服务器,它说推送已成功发送,但设备未收到推送通知。
服务器响应 服务器响应
观察:
- iOS:当我将应用程序从 GCM 更新到 FCM 时,我得到了一个新令牌。
- 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 令牌 - 不工作
解决方案
推荐阅读
- php - 如何使用数据库中存储的数据检查选项底部
- android - 如何在 android studio 中添加电子商务购物车系统
- c++ - 在普通对象安全的任何上下文中,原子对象是否不安全?
- java - 如何修复“无法创建 ViewModel 类的实例”?
- javascript - 如何使用 javascript / ajax 在 HTML 页面上使用 API GET 请求来检索数据?
- caching - LazyCache:定期刷新缓存项
- discord.js - ReferenceError:消息未定义随机弹出
- arrays - 是否可以在 bash 数组中循环遍历 OSX 钥匙串证书?
- tsql - CASE SQL 语句中的比较符号“大于”和“等于”
- c - 在 C 中返回结构指针数组的函数签名的语法是什么?