firebase / FirebaseUI-iOS

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

i want to send phone number to the firebase phone auth ui. but i think im not getting any info about that. #306

Closed nikhilborana closed 7 years ago

nikhilborana commented 7 years ago
                            let authVC = FUIAuth.defaultAuthUI()
                            authVC?.delegate = self

                            let phone = FUIPhoneAuth(authUI: authVC!)
                            authVC?.providers = [phone]

                            phone.signIn(withPresenting: self)
morganchen12 commented 7 years ago

To clarify, you want an API to send the user's phone number somewhere when they log in?

nikhilborana commented 7 years ago

I just want to give the number to the number field in firebase auth UI. Is their anyway to give the number by code. So, user don't have to write phone number again when verify the number.

morganchen12 commented 7 years ago

I see. This seems like a reasonable feature request @yramanchuk

yramanchuk commented 7 years ago

There's no official way to retrieve phone number on iOS device, thus adding phone number param is useless. @nikhilborana please specify which use case do you have.

nikhilborana commented 7 years ago

my app flow is I first register the user with details, and then i move him to firebase phone auth ui. and then the user have to fill the phone number again, i just want to pass phone number when switching user to the verification vc.

its like we do in digits,

func didTapButton(sender: AnyObject) {
    let digits = Digits.sharedInstance()
    let configuration = DGTAuthenticationConfiguration(accountFields: .DefaultOptionMask)
    configuration.phoneNumber = "+345555555555"
    digits.authenticateWithViewController(nil, configuration: configuration) { session, error in
        // Country selector will be set to Spain and phone number field will be set to 5555555555
    }
}
yramanchuk commented 7 years ago

@nikhilborana I will start internal discussion. By my initial estimate is not less than 3 weeks. To help expedite process can you please clarify:

  1. Do you expect that on phone entry screen phone# entry field will be not editable?
  2. Do you want to skip first screen at all?
nikhilborana commented 7 years ago

It can be editable, because if user doesn't type the correct phone number previous, he can also edit on the verification screen, it also helps user to select the country code on the verification screen and it also available in digits, it's awesome if you can make it skip-able, but for most of the users, the first screen is needed.

thanks.

reeltimeapps commented 7 years ago

+1 for the enhancement, this is exactly how we do it with digits currently. Is their a timeframe for this enhancement before the digits shutdown?

ifrizy commented 7 years ago

@yramanchuk Do you have any news about possibility to first register the user with login/password details, and then on next screen perform phone number validation, same as we are doing now with Digits?

nikhilborana wrote about it above:

first register the user with details, and then i move him to firebase phone auth ui. and then the >>user have to fill the phone number again, i just want to pass phone number when switching user >>to the verification vc.

its like we do in digits,

func didTapButton(sender: AnyObject) { let digits = Digits.sharedInstance() let configuration = DGTAuthenticationConfiguration(accountFields: .DefaultOptionMask) configuration.phoneNumber = "+345555555555" digits.authenticateWithViewController(nil, configuration: configuration) { session, error in // Country selector will be set to Spain and phone number field will be set to 5555555555 } }

yramanchuk commented 7 years ago

@nikhilborana Issue was fixed in FIrebaseUI 4.3.0 Please use next func: https://github.com/firebase/FirebaseUI-iOS/blob/master/samples/swift/FirebaseUI-demo-swift/Samples/Auth/FUIAuthViewController.swift#L146

ifrizy commented 7 years ago

@yramanchuk I have tried using this method provider.signIn(withPresenting: self, phoneNumber: nil). However, after calling the method I got "Enter phone number" screen where I could enter Country and Number. After entering and pressing Verify, I received no SMS to the number. Here is the code I tried first:

fileprivate func startOnboarding(completion: @escaping (Error?) -> Void)
    {
        DispatchQueue.main.async {
            let fuiAuthViewController = FUIAuthViewController()
            fuiAuthViewController.customAuthUIDelegate = self

            fuiAuthViewController.authUI?.providers = fuiAuthViewController.getListOfIDPs()
           \\.getListOfIDPs() method was taken from your URL above
            let provider = fuiAuthViewController.authUI?.providers.first as! FUIPhoneAuth
            provider.signIn(withPresenting: self, phoneNumber: nil)
        }
 }

We expected the widget to work by itself and send SMS, but it did not. Then I thought maybe I need to trigger sending SMS myself and did it like this:

fileprivate func startOnboarding(completion: @escaping (Error?) -> Void)
    {

        DispatchQueue.main.async {
            let fuiAuthViewController = FUIAuthViewController()
            fuiAuthViewController.customAuthUIDelegate = self

            fuiAuthViewController.authUI?.providers = fuiAuthViewController.getListOfIDPs() 
            \\.getListOfIDPs() method was taken from your URL above
            let provider = fuiAuthViewController.authUI?.providers.first as! FUIPhoneAuth

            provider.signIn(withDefaultValue: nil, presenting: self, completion: {
                (authCredentials, error, authResultCallback) in
                print("test")

                PhoneAuthProvider.provider().verifyPhoneNumber("+375291234567") { (verificationID, error) in
                    if ((error) != nil) {
                        print(error)
                    } else {
                        UserDefaults.standard.set(verificationID, forKey: "firebase_verification")
                        UserDefaults.standard.synchronize()
                    }
                }
            })
        }

When doing like this, I also get the widget, enter the number and click Verify, but in debug I see the process does not go into .verifyPhoneNumber so this does not work as well.

Can you please let us know how exactly we should use the functionality and if you have any documentation regarding this.

To remind about the registration flow we were trying to achieve: user starts registration on step 1 with either facebook/google/login+password and we create such account in firebase, then on step 2 we want user to enter and verify phone number (no additional firebase account needs to be created). This flow is how it currently works using Digits and will stop in a week.

Thanks!

Nyariki commented 4 years ago

How to do this on Android?