Is there a replacement for using NSNotificationCenter and kFIRInstanceIDTokenRefreshNotification to detect expired tokens?

Viewed 496

I'm migrating some old Crashlytics code that used the now-deprecated

[FIRInstanceID instanceIDWithHandler:] method to use the new

[FIRInstallations installationIDWithCompletion:] method.

Related to that cleanup is the deprecation warning: 'kFIRInstanceIDTokenRefreshNotification' is deprecated.

In the past, we had added an observer to NSNotificationCenter with that name, in order to be notified when the instanceID expired so we could request a new one.

Is there a similar concept for the new installation IDs? I couldn't find any reference to a replacement in the relevant Firebase documentation, but I wonder if I'm simply overlooking something?

1 Answers

I went digging around in the Firebase libraries for a more helpful deprecation message. I found this in FIRInstanceID:

__deprecated_msg("FIRInstanceID is deprecated, please use FIRInstallations for installation "
                 "identifier handling and use FIRMessaging for FCM registration token handling.")

After looking in both FIRInstallations.h and FIRMessaging.h, it looks like they've replaced that one notification name with two:

  • FIRMessagingRegistrationTokenRefreshedNotification
  • FIRInstallationIDDidChangeNotification

So if you're concerned with the installation identifier changing, it looks like you'd want to add an observer to NSNotificationCenter for FIRInstallationIDDidChangeNotification.

Related