firebase / FirebaseUI-iOS

iOS UI bindings for Firebase.
Apache License 2.0
1.51k stars 475 forks source link

Sign-in with a single provider: Cancelling is silent in iOS13+ #809

Open Ruberik opened 4 years ago

Ruberik commented 4 years ago

The issue

In iOS 13, on the iPhone 8 emulator, in Swift.

It's possible to start the sign-in for a single provider. Code is at the bottom.

The problem is that the caller apparently has no control over how the phone auth window is presented. In iOS13, it's presented on about 90% of the screen, meaning that the presenting UIViewController is still visible. If the user cancels, or dismisses the window by swiping down, neither the delegate nor the presenting UIViewController has a way of finding out that cancellation happened. Prior to iOS13, because the sign-in window occluded the original UIViewController, its viewWillAppear method would be called when the sign-in window got out of the way.

A few ideas about how to fix this:

Steps to reproduce:

  1. Run the code above.
  2. Hit "cancel" or swipe down.
  3. Try to write code to detect that the sign-in window disappeared without modifying FirebaseUI.

Observed Results:

Expected Results:

Relevant Code:

    let auth = Auth.auth(app: FirebaseApp.app()!)
    let authUI = FUIAuth(uiWith: auth)!
    authUI.delegate = self
    let phoneAuth = FUIPhoneAuth(authUI: authUI)
    authUI.providers = [phoneAuth]
    phoneAuth.signIn(withPresenting: viewController, phoneNumber: nil)
Ruberik commented 4 years ago

In case it's helpful, my use case is:

Once the user has logged in with the email provider or the Google provider, I ask if she'd like to add a phone number to her account. If so, I present the FUIPhoneAuth login, do some gymnastics to connect the two accounts, and silently log the user back in to her email-based account.

When the phoneAuth process is complete (with either a login or a cancellation), I start another UIViewController to get a profile picture for the user. I can't do this, though, if I can't tell when the phoneAuth step was cancelled.

morganchen12 commented 4 years ago

May be related to this comment.

Ruberik commented 4 years ago

Perfect, thank you.

Ruberik commented 4 years ago

I closed this too quickly. I do actually want it to be possible for the user to cancel; I just want to know if it happened. You're right that that's related, though.

Incidentally, I set authUI.shouldHideCancelButton = true, but interactive dismissal was still possible, which I thought was resolved with #789.

morganchen12 commented 4 years ago

I'll try to find some time to work on this over the holiday season.

To disable interactive dismissal, use the interactiveDismissEnabled property.

Ruberik commented 4 years ago

Thank you, that's a great workaround.

Please don't consider this work urgent on the timescale of a month on my account. I hope you have a happy and restful holiday season.

rajAppmetry commented 4 years ago

How can we set modalPresentationStyle for each and every Auth Controllers separately (FUIEmailAuth,FUIGoogleAuth,FUIFacebookAuth,FUIPhoneAuth)?

morganchen12 commented 4 years ago

@rsekharAppyog currently you cannot without modifying FirebaseUI code.