【问题标题】:FirebaseInstallations will not work correctly with current version of Firebase Instance ID. Please update your Firebase Instance ID versionFirebaseInstallations 无法与当前版本的 Firebase 实例 ID 一起正常工作。请更新您的 Firebase 实例 ID 版本
【发布时间】:2021-09-04 00:58:23
【问题描述】:

我正在使用 Xcode 12.4 并将 cocoapods 升级到 1.10.1 并更新了我所有的 Firebase pod。之后,当我运行该项目时,我不断收到InstanceID() 错误。然后我用谷歌搜索,结果是 FirebaseInstanceID is deprecated 我不得不使用 Firebase/Installations:

// add this to the podfile
pod 'Firebase/Installations'

$ pod install

Firebase/Installations 更新后,我不断收到错误消息:

FirebaseInstallations 无法与当前版本的 Firebase 实例 ID。请更新您的 Firebase 实例 ID 版本。

这没有任何意义,因为 FirebaseInstanceID 已被弃用,所以我该如何更新它。我关注了这个GitHub thread,但没有任何帮助。

【问题讨论】:

标签: ios swift firebase


【解决方案1】:

我为此花了几个小时。我不明白他们为什么会出现请更新您的 Firebase 实例 ID 版本的错误。为了解决这个问题,我必须从我的 podfile 中删除 FirebaseInstanceID

// add a # sign in front of FirebaseInstanceID inside your podfile
#pod 'FirebaseInstanceID'

// then run
$ pod install

在 AppDelegate 中,我必须删除 import FirebaseInstanceID

import FirebaseInstanceID // delete this

为了获得令牌,我遵循了这个答案https://stackoverflow.com/a/64248707/4833705

替换这个不推荐使用的方法:

InstanceID.instanceID().instanceID { (result, error) in { }

有了这个:

Messaging.messaging().token { (token, error) in { }

旁注如果您遇到错误,您可能需要删除并重新安装所有 pod,但这不是必需的。

确保在执行这些步骤之前制作 Podfile 的副本。

$ sudo gem install cocoapods-deintegrate

$ sudo gem install cocoapods-deintegrate cocoapods-clean

$ rm -rf ~/Library/Developer/Xcode/DerivedData

$ pod deintegrate

$ pod clean

$ rm Podfile

$ pod cache clean --all

$ pod init

打开新的 Podfile 然后添加副本中的所有内容

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-27
    • 1970-01-01
    • 1970-01-01
    • 2022-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多