ios - 模拟器FirebaseAuth可以使用!但不是物理设备。错误“ token 不匹配”

标签 ios swift firebase authentication firebase-authentication

我正在尝试为iOS应用实现Phone-Auth。

我收到来自error.localizedDescription的错误: token 不匹配。

这是什么意思? “ token 不匹配”对我无语...

另外,我收到此错误:“此虚假通知应转发到Firebase Auth。”

码:

PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber, uiDelegate: nil) { (verificationID, error) in
                if let error = error {
                    print(error.localizedDescription)

                    return
                }
                // Sign in using the verificationID and the code sent to the user
                // ...

AppDelegate:
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        let firebaseAuth = Auth.auth()
        firebaseAuth.setAPNSToken(deviceToken, type: AuthAPNSTokenType.prod)

    }

    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
                     fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

        let firebaseAuth = Auth.auth()
        if (firebaseAuth.canHandleNotification(userInfo)){
            print(userInfo)
            return
        }

        // Print full message.
        print(userInfo)

        completionHandler(UIBackgroundFetchResult.newData)
    }

最佳答案

我解决了问题,启用电话身份验证后,我们必须再次下载GoogleService-Info.plist以覆盖旧的

关于ios - 模拟器FirebaseAuth可以使用!但不是物理设备。错误“ token 不匹配”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56724802/

相关文章:

javascript - Package.json 复杂的启动脚本,带有 "sh -ac"和用于 Firebase 的 .env 文件

forms - polymer 1.0 : Two-way data binding: <iron-form> to/from Firebase

ios - didReceiveNotificationRequest :withContentHandler - execution time limit?

ios - 我们可以修改 iOS 中的 UIViewController 属性吗?

iphone - 从上次打开的 UIViewController 打开应用程序

ios - 使用reuseIdentifier初始化UICollectionViewCell

ios - 如何在 Swift 中的自定义类中初始化 Timer?

swift - swift 中的功能类型注释

ios - GCD 通过cancellable_dispatch_after 停止

firebase - 有没有办法通过 UID 从 FirebaseAuth 中删除用户?