【问题标题】:Firebase phone Authentication failesFirebase 电话身份验证失败
【发布时间】:2018-12-06 08:18:20
【问题描述】:

我想使用电话身份验证进行 Firebase 登录。 由于我正在开发并且我无法访问设备和 Apple 开发者帐户,所以我使用

来实现此功能

reCAPTCHA 验证

但我收到以下错误

{"error":{"code":403,"message":"来自这个 ios 客户端的请求 应用程序被阻止。","errors":[{"message":"请求来自 这个 ios 客户端应用程序是 被阻止。","domain":"global","re​​ason":"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


【解决方案1】:

我关注了this answer,它成功了。

"将 Google 控制台中的 API 密钥密钥限制设置为 NONE"

我很困惑,因为如果只有 NONE 有效,它的目的是什么?

【讨论】:

    猜你喜欢
    • 2020-05-22
    • 2018-10-09
    • 2019-03-11
    • 2018-03-27
    • 2021-07-13
    • 1970-01-01
    • 2020-12-15
    相关资源
    最近更新 更多