简体   繁体   中英

Cannot get FCM Notification in some device in iOS

In my app I am using FCM push notification using swift3 . 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. We recheck this.
  2. How to know when the FCM token is expire from back end?
  3. Can we get Forcefully get FCM token for every time app launch?
  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. Use the didRefreshRegistrationToken method to get the updated token

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 token does not expire. It changes though on following situations:

The app deletes Instance 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?

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

Why some device not get the notifications. All devices FCM token are store into the sever successfully. 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

Hope this helps you!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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