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

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.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 18 (4 by maintainers)

Most upvoted comments

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

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

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

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

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

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.