[英]Error signing in using FirebaseAuth in a Flutter app using a physical iOS device
[英]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.