Firebase-ios-sdk: Firebase Auth - Phone Auth not working on iOS 13 with SwiftUI

Created on 27 Aug 2019  路  18Comments  路  Source: firebase/firebase-ios-sdk

#### Development Environment:

  • Xcode version: 11 beta 6
  • Firebase SDK version: 6.7.0
  • Firebase Component: Auth
  • Component version: 6.2.3

Steps to reproduce:

  1. Create a new SwiftUI project and add the Firebase Core and Auth SDKs using Cocoapods
  2. Set up the project for Phone Auth.
  3. Create the UI for the user to provide their phone.
  4. Call verifyPhoneNumber:UIDelegate:completion using the phone provided.
  5. A webView opens in order for you to solve a reCaptcha.
  6. Solve the reCaptcha.
  7. Get an about:blank page
  8. The dismiss delegate is never called.

I am guessing this might have to do something with the new SceneDelegate, but I am not sure.

auth iOS 13

Most helpful comment

Not only SwiftUI, but also UIKit has same. If you use SceneDelegate, we should add below and it works for me.

    func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
        for urlContext in URLContexts {
            let url = urlContext.url
            Auth.auth().canHandle(url)
        }
    }

All 18 comments

I can confirm this is still an issue with Xcode11 GM (11A419c).

Been stuck for hours thinking I am doing something wrong :(
Any workaround would be great, This halts many things because reCaptcha comes up on emulator even with test numbers (Why?!)
BTW: I am using SwiftUI too

This is no longer a beta-software issue.

Been stuck for hours thinking I am doing something wrong :(
Any workaround would be great, This halts many things because reCaptcha comes up on emulator even with test numbers (Why?!)
BTW: I am using SwiftUI too

you can use Integration testing until they fix this issue

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.

https://firebase.google.com/docs/auth/ios/phone-auth#integration-testing

Been stuck for hours thinking I am doing something wrong :(
Any workaround would be great, This halts many things because reCaptcha comes up on emulator even with test numbers (Why?!)
BTW: I am using SwiftUI too

you can use Integration testing until they fix this issue

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.

https://firebase.google.com/docs/auth/ios/phone-auth#integration-testing

It helped a lot, Thanks馃憣馃徎

Hi @nikolouzos, could you help try the fix on the brach "swift-ui"?

You can do that by changing your podfile to

pod 'FirebaseAuth', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'swift-ui'
pod 'GoogleUtilities', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :branch => 'swift-ui'

Please let me know if the fix works for you, also please confirm that the fix doesn't affect your existing code.

@nikolouzos facing similar issue here, where you able to resolve it?

Integration testing did work but its showing about:blank page after reCaptcha when isAppVerificationDisabledForTesting = false

Checked it on iOS 13.1.2, using Xcode 11 , FirebaseAuth version 6.3.0

While we're working on the fix, please check out the last code snippet of https://firebase.google.com/docs/auth/ios/phone-auth#appendix:-using-phone-sign-in-without-swizzling for a workaround. Note that you don't have to disable swizzling.

I tried it by add to appDelegate
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { for urlContext in URLContexts { let url = urlContext.url Auth.auth().canHandle(url) } }
but it didn't work still about:blank
checked it on Xcode 11 with the simulator
I'm using Storyboard not SwiftUI

While we're working on the fix, please check out the last code snippet of https://firebase.google.com/docs/auth/ios/phone-auth#appendix:-using-phone-sign-in-without-swizzling for a workaround. Note that you don't have to disable swizzling.

after adding above snippet, it still showed about:blank page

Please make sure it's added to your SceneDelegate, not ApplicationDelegate.

Thank you It worked
but the code snippet
func scene(_ scene: UIScene, openURLContexts URLContexts: Set)
give error Reference to generic type 'Set' requires arguments in <...>
according to Apple documentation it should be
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>)

still no update ? for ios 13 ?

reCaptcha is not working on ios 13 with out swift ui too

Not only SwiftUI, but also UIKit has same. If you use SceneDelegate, we should add below and it works for me.

    func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
        for urlContext in URLContexts {
            let url = urlContext.url
            Auth.auth().canHandle(url)
        }
    }

The latest release (FirebaseAuth 6.4.1, GoogleUtilities 6.4.0) should fix this issue and you don't have to manually override the method like above any more. Please let me know if it works for you.

I've jus tried with FirebaseAuth 6.4.1 and I still see a blank page when the reCAPTCHA page is opened. Using iOS 13.3.

@NeverwinterMoon there is problem with recaptcha process. I was facing same. Please check this thread. https://github.com/firebase/firebase-ios-sdk/issues/4177

Was this page helpful?
0 / 5 - 0 ratings