I have used Firebase AuthUI in my app to login using google, phone and email methods. I need to store data on Firestore after successful authentication.
The code I have used for launching Firebase Auth Screen with diff providers listed :
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setIsSmartLockEnabled(false, true)
.setLogo(R.drawable.yam_logo_orange_512)
.setAvailableProviders(Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.PhoneBuilder().build()
)).build(),
RC_SIGN_IN);
But, as I wrote down above - I am using AuthUI that provides default buttons and UI - I don't have ownership of the phone number field and same for the phone number.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
String providerType = response.getProviderType();
if (resultCode == RESULT_OK) {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
switch (providerType) {
case Constants.PROVIDER_GOOGLE:
account = GoogleSignIn.getLastSignedInAccount(this);
if (account != null) {
firebaseAuthWithGoogle(account, response.isNewUser());
}
break;
case Constants.PROVIDER_PHONE:
if(null!=phoneAuthCredential){
signInWithPhoneAuthCredential(phoneAuthCredential, response.isNewUser());
}
break;
case Constants.PROVIDER_EMAIL:
break;
}
}
}
}
}
Please help me in completing this. Do I need to make a custom screen to get the number and then register PhoneAuth callback?
Thanks, Kanak