3

I have an app that uses Firebase for push notifications. I can hand Firebase my APNS Token and I get an FCM token, which I can use to push to that device from the Firebase console.

If the user disables push notification in the app (not the iOS settings app), I unregister the FCM token using the deleteFcmToken method. If they subsequently re-enable notifications, I use retrieveFcmToken to request a new one. But I've noticed that when I request a new one, I get the same one as what I had before I deleted it, and if I try to push to my device from the Firebase console with that token, it doesn't work.

How can I forcefully refresh a Firebase push token? Do I have to wait some minimum amount of time for some cache in Firebase to be cleared or something? Or is there a different API I should be using?

Tom Hamming
  • 10,577
  • 11
  • 71
  • 145
  • I haven't dabbled with iOS that much yet, but [for Android side we use `deleteInstanceId()`](https://stackoverflow.com/a/43197589/4625829). Try using [`FIRInstanceId`](https://firebase.google.com/docs/reference/ios/firebaseinstanceid/api/reference/Constants.html#/c:@kFIRInstanceIDTokenRefreshNotification)'s `deleteInstanceId` counterpart while listening for changes in [`kFIRInstanceIDTokenRefreshNotification`](https://firebase.google.com/docs/reference/ios/firebaseinstanceid/api/reference/Constants.html#/c:@kFIRInstanceIDTokenRefreshNotification) then get the token. – AL. Sep 22 '19 at 08:04
  • Also for a brief idea on the difference between the registration token vs the instance ID, [this post](https://stackoverflow.com/a/45140083/4625829) might help. – AL. Sep 22 '19 at 08:08

0 Answers0