ios - Firebase 电话身份验证失败
问题描述
我想使用电话身份验证进行 Firebase 登录。由于我正在开发并且我无权访问设备和 Apple 开发人员帐户,所以我去使用实现此功能
reCAPTCHA 验证
但我收到以下错误
{"error":{"code":403,"message":"来自此 ios 客户端应用程序的请求被阻止。","errors":[{"message":"来自此 ios 客户端应用程序的请求被阻止。", “域”:“全局”,“原因”:“禁止”}],“状态”:“PERMISSION_DENIED”}}
正如文档中所示,我已经实现了这一点。
下面是 AppDelegate.swift 中的代码:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}
// For iOS 9+
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
if Auth.auth().canHandle(url) {
return true
}
return false
// URL not auth related, developer should handle it.
}
下面是 ViewController.swift 中的代码:
@IBAction func didTapSignUp(_ sender: Any) {
PhoneAuthProvider.provider().verifyPhoneNumber("+919637892151", uiDelegate: nil) { (verificationId, error) in
if let error = error {
// It always comes here
print(error.localizedDescription)
}
if let verificationId = verificationId {
print(verificationId)
UserDefaults.standard.set(verificationId, forKey: "authVerificationID")
}
}
}
解决方案
推荐阅读
- php - PHP/SQL 分组
- regex - 正则表达式匹配字符串并忽略区分大小写
- google-classroom - 仅限 Google Classroom API 访问
- wordpress - 如何限制商店经理编辑订单价格
- openssl - Openshift:创建直通安全路由
- spring - 在 Spring Boot Hibernate 中覆盖默认表模式
- c# - 为 SQL 连接字符串模拟用户 c# MVC
- arrays - 使用 $exists 的 MongoDB 查询和数组
- jupyter-notebook - 如何在不执行单元格的情况下加载 jupyter-notebook
- machine-learning - 机器学习中的差异结果