firebase / FirebaseUI-iOS

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

Get phone number from FUIPhoneAuth instance #857

Open willbattel opened 4 years ago

willbattel commented 4 years ago

Step 1: Are you in the right place?

Step 2: Describe your environment

Step 3: Describe the problem:

We're using FUI for phone authentication. In the event on a merge conflict, where we do not get an AuthDataResult, I want to retrieve the phone number that the user provided from within the authUI(_:didSignInWith:error:) delegate function (before we do signIn, where we would then be able to get it directly from FIRAuth). What I think would make the most sense would be to add it as a property on the FUIPhoneAuth class similar to how we can get the email with authUI.providers.first?.email?(). Would this change be feasible?

willbattel commented 4 years ago

Hey @morganchen12 could I get your thoughts on this as a short-term solution to #851? I know it will be some time before 851 can be implemented, so as a workaround I'd like to get the phone number to do a Firestore lookup for finding the UID manually. As far as I can tell, there isn't a way for us to intercept the phone number provided by the user in the FUI flow.

morganchen12 commented 4 years ago

The best way to do that would be to fork FirebaseUI, add the workaround there, and point your CocoaPods installation to your fork.

willbattel commented 4 years ago

Regardless of my use case, would it not make sense to expose a phoneNumber property on the FUIPhoneAuth class? It already has an email property- so it seems like providing the phone number would make sense. Is this thought misguided?

morganchen12 commented 4 years ago

That thought makes sense. User identifiers (like phone/email) should be attached to the specific providers for those identifiers.