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

6

11

After recaptcha verification, page only returned blank. It did nothing to do next step.

Screen Shot

Screen Shot

Autolithography answered 26/5, 2018 at 7:29 Comment(4)
Did you make sure to set us your custom scheme URL coderwall.com/p/mtjaeq/ios-custom-url-schemeGigi
I sure that I did all requirement.Autolithography
The custom scheme redirect is not working for some reason in your app. That is the first thing that comes to mind, that you have not configured the custom scheme URL correctly.Gigi
Hi, did you solve the problem? My application was working normally, but out of nowhere, it started to return white page from recaptcha.Omnipotence
P
16

In your app delegate's application(_:open:options:) method, call Auth.auth().canHandle(url).

Polycrates answered 10/12, 2018 at 0:13 Comment(5)
Certainly, it is the correct answer. You need to handle deep link redirection to catch that callback from reCaptcha.Socman
I'm using react native and encounter the same issue, will this be helpful for me?Sullen
Should be marked as the correct answer and works for iOS 13.Plagiarize
Thanks a lot. This solution works! By the way, how do you know we should add this code? I cannot find where firebase doc specify this.Sieber
@WuYuanChun This is explain in the 'Appendix: Using phone sign-in without swizzling' section of the doc here: firebase.google.com/docs/auth/ios/…Polycrates
K
5

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).

enter image description here

2nd thing-

  1. In the project navigator select the blue project icon

  2. Select Capabilities

  3. Open Background Modes

  4. Select Background fetch

enter image description here

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
    }
}
Kilogrammeter answered 15/2, 2019 at 10:51 Comment(0)
A
2

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

Arianaariane answered 16/12, 2019 at 18:15 Comment(0)
A
1

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;
                       }
             }
Abed answered 23/6, 2021 at 11:19 Comment(0)
Q
0

If Anyone came a across such issu, Try this.

// Before verifyPhoneNumber Method

Auth.auth().settings?.isAppVerificationDisabledForTesting = true


       PhoneAuthProvider.provider().verifyPhoneNumber( ....
Quit answered 27/3, 2023 at 20:44 Comment(0)
H
0

In case anyone reads this using SwiftUI. For me the problem was solved by attaching

.onOpenURL { url in
   Auth.auth().canHandle(url)
}

to the first View of my app (right where you can find @main).

Hulking answered 24/8, 2024 at 9:6 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.