简体   繁体   English

recaptcha 验证后的空白页使用电话号码 Swift 在 iOS 上使用 Firebase 进行身份验证

[英]blank page after recaptcha verification Authenticate with Firebase on iOS using a Phone Number Swift

After recaptcha verification, page only returned blank. recaptcha验证后,页面只返回空白。 It did nothing to do next step.它没有做下一步。

Screen Shot截屏

截屏

在您的应用程序委托的application(_:open:options:)方法中,调用Auth.auth().canHandle(url)

For the blank re-captcha page issue I was able to resolve it by doing these 3 things:对于空白的重新验证码页面问题,我可以通过执行以下 3 件事来解决它:

1st thing-第一件事——

  1. Inside the GoogleSerivce-Info.plist file make sure the REVERSED_CLIENT_ID is added to your project via the URL types using this .GoogleSerivce-Info.plist文件中,确保使用 thisREVERSED_CLIENT_ID通过 URL 类型添加到您的项目中。 Follow the first part of the second step there: Add custom URL schemes to your Xcode project (look at the screenshot).遵循第二步的第一部分:将自定义 URL 方案添加到您的 Xcode 项目(查看屏幕截图)。

在此处输入图片说明

2nd thing-第二件事——

  1. In the project navigator select the blue project icon在项目导航器中选择blue project icon

  2. Select Capabilities选择Capabilities

  3. Open Background Modes打开Background Modes

  4. Select Background fetch选择Background fetch

在此处输入图片说明

3rd thing-第三件事——

  1. Before verifying the phone number call PhoneAuthProvider.provider(auth: Auth.auth())在验证电话号码之前调用PhoneAuthProvider.provider(auth: Auth.auth())
@IBAction func phoneButton(sender: UIButton) {

    // ***step 5***
    PhoneAuthProvider.provider(auth: Auth.auth())

    PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumberTextField.text!, uiDelegate: nil) {
        (verificationID, error) in
            
        if let error = error {
            print(error.localizedDescription)
            return
        }
            
        guard let verificationId = verificationID else { return }

        // do something with verificationID
    }
}

On iOS, the appVerificationDisabledForTesting setting has to be set to TRUE before calling verifyPhoneNumber.在 iOS 上,appVerificationDisabledForTesting 设置必须在调用 verifyPhoneNumber 之前设置为 TRUE。 This is processed without requiring any APNs token or sending silent push notifications in the background, making it easier to test in a simulator.无需任何 APNs 令牌或在后台发送静默推送通知即可处理此操作,从而更容易在模拟器中进行测试。 This also disables the reCAPTCHA fallback flow.这也会禁用 reCAPTCHA 回退流程。

Firebase Docs Firebase 文档

I face this issue and fix it by adding this code into my AppDelegate.m我面临这个问题并通过将此代码添加到我的 AppDelegate.m 来解决它

- (BOOL) application: (UIApplication *) app
             openURL: (NSURL *) url
             options: (NSDictionary <UIApplicationOpenURLOptionsKey, id> *) 
               options {
                      if ([[FIRAuth auth] canHandleURL: url]) {
                           return YES;
                       } else {
                       // URL not auth related, developer should handle it.
                          return NO;
                       }
             }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift使用电话号码在iOS上使用Firebase进行身份验证,导致崩溃 - Swift Authenticate with Firebase on iOS using a Phone Number causing crash 使用电话号码iOS对Firebase进行身份验证 - Authenticate with Firebase using Phone Number iOS 如何使用 firebase 为 IOS Flutter 禁用电话验证中的重新验证 - How to disable recaptcha verification in phone Authentication with firebase for IOS Flutter Firebase (Flutter) 验证电话号码始终需要 reCAPTCHA - Firebase (Flutter) authenticate phone number always requires reCAPTCHA Firebase 电话身份验证在 iOS 上弹出 reCAPTCHA 验证 window 即使后台模式和推送通知已启用 - Firebase Phone Authentication pops up a reCAPTCHA verification window on iOS even if Background Modes and Push Notifications are enabled Firebase验证电话号码,然后使用Swift使用电子邮件/密码对用户进行身份验证 - Firebase verify phone number then authenticate user with email/password with Swift Firebase 用户电话号码验证 - Firebase user phone number verification Firebase 电话身份验证 reCAPTCHA 验证在某些设备上不起作用 - Firebase Phone Auth reCAPTCHA verification not working on some devices 尝试使用 firebase 验证电话号码时出现“无效令牌” - "Invalid Token" when trying to authenticate phone number using firebase 在 IOS 中使用电话号码登录 Firebase - Login to Firebase using phone number in IOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM