简体   繁体   中英

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

After recaptcha verification, page only returned blank. 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:

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 . Follow the first part of the second step there: Add custom URL schemes to your Xcode project (look at the screenshot).

在此处输入图片说明

2nd thing-

  1. In the project navigator select the blue project icon

  2. Select Capabilities

  3. Open Background Modes

  4. Select Background fetch

在此处输入图片说明

3rd thing-

  1. Before verifying the phone number call 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. This is processed without requiring any APNs token or sending silent push notifications in the background, making it easier to test in a simulator. This also disables the reCAPTCHA fallback flow.

Firebase Docs

I face this issue and fix it by adding this code into my 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;
                       }
             }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM