Firebase:Firebase InstallationID 和 fcmToken 之间的区别

Firebase: Difference between Firebase InstallationID and fcmToken

在 Firebase 中 InstallationID and fcmToken or token 不同还是相同。如果它们不同,那又如何呢?

migration guide 中没有清楚地解释它们有何不同。它确实提到 InstanceIDInstallationsID[=30= 有何不同]

在他们的文档中提到了关于令牌

This creates a Firebase Installations ID, if one does not exist, and sends information about the application and the device to the Firebase backend. A network connection is required for the method to succeed.

如果有人使用 token API 注册令牌然后 migration guide 说我们必须替换它,这会更加混乱

Installations.installations().installationID { (id, error) in
  if let error = error {
    print("Error fetching id: \(error)")
    return
  }
  guard let id = id else { return }
  print("Installation ID: \(id)")
}

总而言之,安装 ID 在设备内使用并作为自引用,因此该应用能够将自己与其他应用区分开来。因为多个应用程序可能使用 firebase 作为它们的主要应用程序驱动程序。

FCM 令牌是为设备生成的令牌,也用于识别相关设备,但用于在通知网络中识别设备,而不是在其他应用程序内部识别设备。

两者都以类似的方式用于识别设备和应用程序,但最终用于不同的目的。如果您正在处理 Firebase Messaging,则需要引用 FCM 令牌。