繁体   English   中英

模拟器 FirebaseAuth 有效! 但不是物理设备。 错误“令牌不匹配”

[英]Simulator FirebaseAuth works! But not a physical device. Error 'Token Mismatch'

我正在尝试为 iOS 应用实现电话验证。

我从 error.localizedDescription 收到错误消息:令牌不匹配。

这是什么意思? “令牌不匹配”对我没有任何意义......

此外,我收到此错误:“此虚假通知应转发给 Firebase 身份验证。”

代码:

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
                // ...

应用委托:

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 以覆盖旧的

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM