Sign-in with a single provider: Cancelling is silent in iOS13+
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:
- On viewWillDisappear or something like it, call a method of the delegate to say "I'm done and the user didn't sign in."
- Have the provider login UI presented full-screen instead of default.
- Instead of the current phoneAuth.signIn(withPresenting:phoneNumber) starting the UIViewController, have an equivalent method return a UIViewController. The user can then configure the modalPresentationStyle, or add a notification such as in this SO answer (note that I don't actually know whether such notifications work or are desirable).
- Something else I haven't thought of.
Steps to reproduce:
- Run the code above.
- Hit "cancel" or swipe down.
- Try to write code to detect that the sign-in window disappeared without modifying FirebaseUI.
Observed Results:
- I can't figure out how to write code to detect that the sign-in window disappeared.
Expected Results:
- I expected to be able to figure out how to write code to detect that the sign-in window disappeared.
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)
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.
May be related to this comment.
Perfect, thank you.
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.
I'll try to find some time to work on this over the holiday season.
To disable interactive dismissal, use the interactiveDismissEnabled property.
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.
How can we set modalPresentationStyle for each and every Auth Controllers separately (FUIEmailAuth,FUIGoogleAuth,FUIFacebookAuth,FUIPhoneAuth)?
@rsekharAppyog currently you cannot without modifying FirebaseUI code.