我正在使用 Firebase UI 电话身份验证最新版本的 Firebase Auth 构建 iOS 应用程序。
当我尝试在我的设备上使用电话号码执行登录时,似乎不需要 reCAPTCHA 验证并且可以正常工作。
相反,当我尝试在其他设备上运行该应用程序时,它需要 reCAPTCHA 验证,但当完成验证您不是机器人时,我突然看到屏幕保持空白且无法工作。
我在 Stack Overflow 上搜索了一些答案,并提到了在后台模式下启用某些功能(我启用了远程通知、后台获取、IP 语音、音频、Airplay...)。他们提到的关于 GoogleService 文件中的 REVERSED_CLIENT_ID
的其他事情,我必须将该 URL 复制到 URL 方案中,当然我已经复制了它。
以下是我的一些委托(delegate)函数:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
let firebaseAuth = Auth.auth()
if (firebaseAuth.canHandleNotification(userInfo)){
print("User infor ",userInfo)
return
}
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let token = deviceToken.hexString
print("====== This is device token ",deviceToken)
let firebaseAuth = Auth.auth()
// I used to set type .unknown to .prod as well and it doesn't work
firebaseAuth.setAPNSToken(deviceToken, type: .unknown)
InstanceID.instanceID().instanceID { (result, error) in
if let error = error {
NSLog("Error getting instance ID ", error.localizedDescription)
} else if let result = result {
Messaging.messaging().apnsToken = deviceToken
UserDefaults.standard.setFCMToken(value: result.token)
}
}
print("=============== Device token",deviceToken.description)
if let uuid = UIDevice.current.identifierForVendor?.uuidString {
print(uuid)
}
UserDefaults.standard.setValue(token, forKey: "ApplicationIdentifier")
UserDefaults.standard.synchronize()
}
还有什么我错过的吗?为什么它不能在其他 iOS 设备上运行?为什么需要 reCAPTCHA 验证,然后验证后屏幕保持空白??
最佳答案
在请求 VerificationID 之前输入以下代码。
Auth.auth().settings?.isAppVerificationDisabledForTesting = true
关于ios - Firebase Phone Auth reCAPTCHA 验证在某些设备上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57036164/