【发布时间】:2018-12-06 08:18:20
【问题描述】:
我想使用电话身份验证进行 Firebase 登录。 由于我正在开发并且我无法访问设备和 Apple 开发者帐户,所以我使用
来实现此功能reCAPTCHA 验证
但我收到以下错误
{"error":{"code":403,"message":"来自这个 ios 客户端的请求 应用程序被阻止。","errors":[{"message":"请求来自 这个 ios 客户端应用程序是 被阻止。","domain":"global","reason":"forbidden"}],"status":"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")
}
}
}
【问题讨论】:
-
你也在使用 Cordova 吗?
-
不,纯斯威夫特
-
请更新您的问题以包含相关代码和 google plist 文件,以便我们尝试提供帮助
-
您的 API 密钥可能存在一些限制。尝试在 Google Cloud Console 中检查。
-
它与bundleId有关,现在可以正常工作了。
标签: ios swift firebase firebase-authentication