简体   繁体   English

在iOS中的某些设备上无法获取FCM通知

[英]Cannot get FCM Notification in some device in iOS

In my app I am using FCM push notification using swift3 . 在我的应用程序中,我正在使用swift3的 FCM推送通知 When ever app is install in device, some device get the notification and some are not get notified when push came. 在设备中安装过任何应用程序后,某些设备会收到通知,而某些设备不会在推送时收到通知。 When we update a new version without remove the app then cannot get the notification but if remove the app and reinstall it then we get the notifications. 当我们在不删除应用程序的情况下更新新版本时,无法获取通知,但是如果删除应用程序并重新安装,则我们将收到通知。 My question is 我的问题是

  1. Why some device not get the notifications. 为什么某些设备无法收到通知。 All devices FCM token are store into the sever successfully. 所有设备FCM令牌已成功存储到服务器中。 We recheck this. 我们重新检查。
  2. How to know when the FCM token is expire from back end? 如何知道FCM令牌何时从后端过期?
  3. Can we get Forcefully get FCM token for every time app launch? 我们可以在每次启动应用时强制获得FCM令牌吗?
  4. Why some device have "invalid-registration-token" and "token-not-registered" issue? 为什么某些设备出现“无效注册令牌”和“未注册令牌”的问题?

Thanks. 谢谢。 Help is much appreciated! 非常感谢帮助!

You can check if the token is updated by using the FIRMessagingDelegate protocol in your App delegate. 您可以使用App委托中的FIRMessagingDelegate协议检查令牌是否已更新。 Use the didRefreshRegistrationToken method to get the updated token 使用didRefreshRegistrationToken方法获取更新的令牌

func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) {
  print("Firebase registration token: \(fcmToken)")
}

If the token is updated replace the current token with the updated one. 如果令牌已更新,请用已更新的令牌替换当前令牌。

How to know when the FCM token is expire from back end? 如何知道FCM令牌何时从后端过期?

FCM token does not expire. FCM令牌不会过期。 It changes though on following situations: 在以下情况下,它会发生变化:

The app deletes Instance ID. 该应用程序删除实例ID。

The app is restored on a new device. 该应用已还原到新设备上。

The user uninstall/reinstall the app. 用户卸载/重新安装应用程序。

The user clears app data. 用户清除应用程序数据。

Can we get Forcefully get FCM token for every time app launch? 我们可以在每次启动应用时强制获得FCM令牌吗?

print(FIRInstanceID.instanceID().token())

Why some device not get the notifications. 为什么某些设备无法收到通知。 All devices FCM token are store into the sever successfully. 所有设备FCM令牌已成功存储到服务器中。 We recheck this. 我们重新检查。

Follow below answer to have uniformity in registering devices with different OS version for push notification. 请遵循以下答案,以统一注册具有不同操作系统版本的设备以进行推送通知。

https://stackoverflow.com/a/41279265/2432338 https://stackoverflow.com/a/41279265/2432338

Hope this helps you!! 希望这对您有帮助!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM