gpt4 book ai didi

ios - 使用导致崩溃的电话号码在 iOS 上使用 Firebase 进行 Swift 身份验证

转载 作者:搜寻专家 更新时间:2023-10-30 23:07:54 26 4
gpt4 key购买 nike

我正在关注 Firebase 文档: https://firebase.google.com/docs/auth/ios/phone-auth

尝试使用电话号码在 iOS 上使用 Firebase 进行身份验证,当它到达我的代码中时出现致命崩溃:

PhoneAuthProvider.provider().verifyPhoneNumber(self.phoneNumberTextField.text!, uiDelegate: nil) { (verificationID, error) in 

if let error = error {
print("error: \(error.localizedDescription)")
return
}

// Perform Seque to VerifictionCodeViewController
self.performSegue(withIdentifier: "enterVerificationCode", sender: self)
}

错误是:libc++abi.dylib: terminating with uncaught exception of type NSException 在我的 appDelegate.swift 文件中。

如果我使用旧的和“弃用”的函数版本

PhoneAuthProvider.provider().verifyPhoneNumber(self.phoneNumberTextField.text!) { (verificationID, error) in 

if let error = error {
print("error: \(error.localizedDescription)")
return
}

// Perform Seque to VerifictionCodeViewController
self.performSegue(withIdentifier: "enterVerificationCode", sender: self)
}

verifyPhoneNumber 函数中没有新添加的 uiDelegate: nil 部分,一切正常!?

有人能解决这个问题吗??

最佳答案

您需要完成其余的设置。

reCAPTCHA verification: In the event that sending or receiving a silent push notification is not possible, such as when the user has disabled background refresh for your app, or when testing your app on an iOS simulator, Firebase Authentication uses reCAPTCHA verification to complete the phone sign-in flow. The reCAPTCHA challenge can often be completed without the user having to solve anything.

o enable the Firebase SDK to use reCAPTCHA verification:

将自定义 URL 方案添加到您的 Xcode 项目:打开您的项目配置:双击左侧 TreeView 中的项目名称。从 TARGETS 部分选择您的应用程序,然后选择 Info 选项卡,并展开 URL Types 部分。单击 + 按钮,并为您的反向客户端 ID 添加 URL 方案。要查找此值,请打开 GoogleService-Info.plist 配置文件,然后查找 REVERSED_CLIENT_ID 键。复制该键的值,并将其粘贴到配置页面上的 URL Schemes 框中。将其他字段留空。完成后,您的配置应类似于以下内容(但具有特定于应用程序的值):

关于ios - 使用导致崩溃的电话号码在 iOS 上使用 Firebase 进行 Swift 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47957646/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com