是否可以替代使用 NSNotificationCenter 和 kFIRInstanceIDTokenRefreshNotification 来检测过期令牌?

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

我正在迁移一些使用现已弃用的旧 Crashlytics 代码

[FIRInstanceID instanceIDWithHandler:] 使用新方法

[FIRInstallations installationIDWithCompletion:] 方法。

与该清理相关的是弃用警告:'kFIRInstanceIDTokenRefreshNotification' is deprecated

过去,我们使用该名称向 NSNotificationCenter 添加了一个观察者,以便在 instanceID 过期时收到通知,以便我们可以请求一个新观察者。

新安装 ID 是否有类似的概念?我在 the relevant Firebase documentation 中找不到任何关于替换的参考,但我想知道我是否只是忽略了什么?

我在 Firebase 库中四处寻找更有帮助的弃用信息。我在 FIRInstanceID:

中找到了这个
__deprecated_msg("FIRInstanceID is deprecated, please use FIRInstallations for installation "
                 "identifier handling and use FIRMessaging for FCM registration token handling.")

在查看 FIRInstallations.h 和 FIRMessaging.h 之后,他们似乎已将一个通知名称替换为两个:

  • FIRMessagingRegistrationTokenRefreshedNotification
  • FIRInstallationIDDidChangeNotification

因此,如果您担心安装标识符的变化,您可能想要为 FIRInstallationIDDidChangeNotification.

添加一个观察者到 NSNotificationCenter