i am looking for a way to find which code is sent to me from firebase phone authentication because i want to manually verify that code.Now the problem is firebase is autometically detecting the sms and onVerificationCompleted() is called but i have a button and i want to manually enter otp code and verify.Below is my code.Any help would be appreciated.Thanks
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phonenumber,
120,
TimeUnit.SECONDS,
this, new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(#NonNull PhoneAuthCredential phoneAuthCredential) {
Intent intent = new Intent(PhoneVerification.this, PictureActivity.class);
Log.e("iamhere","Credential IS"+phoneAuthCredential);
intent.putExtra("email",email);
intent.putExtra("phoneNumber",phonenumber);
intent.putExtra("password",password);
startActivity(intent);
Toast.makeText(PhoneVerification.this, "Please fill the registration form", Toast.LENGTH_LONG).show();
}
#Override
public void onVerificationFailed(#NonNull FirebaseException e) {
Toast.makeText(PhoneVerification.this, "Failed: "+e.getMessage(), Toast.LENGTH_LONG).show();
}
#Override
public void onCodeSent(#NonNull String s, #NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(s, forceResendingToken);
Toast.makeText(PhoneVerification.this, "Check your phone for verification code", Toast.LENGTH_LONG).show();
String mVerificationId = s;
}
});
In case if code does not get detected automatically, the user has to manually enter it through EditText
loginBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String txt = otpEditText.getText().toString().trim();
if (txt.isEmpty() || txt.length() < 6) {
otp.setError("Enter valid code");
return;
}
//verifying the code entered manually
if (isOnline()) {
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, txt);
signInWithPhoneAuthCredential(credential);
} else {
showSnack(relativeLayout, "Unable to connect! Check internet connection");
}
}
});
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
mAuth.signInWithCredential(credential)
.addOnCompleteListener(Verification.this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
//verification successfull do next task
} else {
//verification unsuccessful.. display an error message
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
Toast.makeText(Verification.this, "Incorrect OTP entered", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(Verification.this, "Unable to verify please retry later", Toast.LENGTH_LONG).show();
}
}
}
});
}
Here is the auto verification:
private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
//Getting the code sent by SMS
String code = phoneAuthCredential.getSmsCode();
//sometime the code is not detected automatically
//in this case the code will be null
//so user has to manually enter the code
if (code != null) {
otpEditText.setText(code);
//verifying the code
verifyVerificationCode(code);
}
}
#Override
public void onVerificationFailed(FirebaseException e) {
FancyToast.makeText(Verification.this, e.getMessage(), FancyToast.LENGTH_LONG, FancyToast.CONFUSING, false).show();
}
#Override
public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(s, forceResendingToken);
//storing the verification id that is sent to the user
mVerificationId = s;
}
};
Check out the Firebase documentation for more info.
Related
I've a project using firebase phoneAuth verification as login method. But after logout, I can't re-login to previous account. It requires new account. But email verification works with re-login. I've check the doc and answer from this page but it seem l haven't got solution to the problem. Is it possible to re-login to previous account firebase phoneAuth ?
verifyBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
String phoneNumber = loginPhoneET.getText().toString();
String phone = "+" + picker.getSelectedCountryCode() + phoneNumber;
if(!Patterns.PHONE.matcher(phoneNumber).matches())
{
loginPhoneET.setError("Invalid phone number");
loginPhoneET.setFocusable(true);
Toast.makeText(LoginActivity.this, "Please enter a valid phone number", Toast.LENGTH_LONG).show();
}
else
{
loadingBar.setTitle("Sending verification code");
loadingBar.setMessage("Please wait...");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phone, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
TaskExecutors.MAIN_THREAD,
//AdminLoginActivity.this, // Activity (for callback binding)
callbacks); // OnVerificationStateChangedCallbacks
}
}
});
loginBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
loginPhoneET.setVisibility(View.INVISIBLE);
verifyBtn.setVisibility(View.INVISIBLE);
String verificationCode = verificationET.getText().toString();
if(TextUtils.isEmpty(verificationCode))
{
Toast.makeText(LoginActivity.this, "Please enter the verification code", Toast.LENGTH_SHORT).show();
}
else
{
loadingBar.setTitle("Verifying code");
loadingBar.setMessage("Please wait...");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, verificationCode);
signInWithPhoneAuthCredential(credential);
}
}
});
callbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(#NonNull PhoneAuthCredential phoneAuthCredential)
{
String code = phoneAuthCredential.getSmsCode();
if (code!=null)
{
verificationET.setText(code);
signInWithPhoneAuthCredential(phoneAuthCredential);
}
}
#Override
public void onVerificationFailed(#NonNull FirebaseException e)
{
loadingBar.dismiss();
Toast.makeText(LoginActivity.this, "Invalid phone number. Please enter a correct phone number", Toast.LENGTH_SHORT).show();
verificationET.setVisibility(View.GONE);
loginBtn.setVisibility(View.GONE);
loginPhoneET.setVisibility(View.VISIBLE);
verifyBtn.setVisibility(View.VISIBLE);
}
#Override
public void onCodeSent(#NonNull String verificationId,
#NonNull PhoneAuthProvider.ForceResendingToken token) {
// Save verification ID and resending token so we can use them later
mVerificationId = verificationId;
mResendToken = token;
loadingBar.dismiss();
Toast.makeText(LoginActivity.this, "Verification code has been sent to your phone.", Toast.LENGTH_SHORT).show();
verificationET.setVisibility(View.VISIBLE);
loginBtn.setVisibility(View.VISIBLE);
loginPhoneET.setVisibility(View.GONE);
verifyBtn.setVisibility(View.GONE);
}
};
}
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
mAuth.signInWithCredential(credential)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task)
{
if (task.isSuccessful()) {
final FirebaseUser user = mAuth.getCurrentUser();
final String uid = user.getUid();
final String phone = user.getPhoneNumber();
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("userId", uid);
hashMap.put("phone", phone);
UsersDataRef.child(uid).setValue(hashMap).addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void aVoid) {
loadingBar.dismiss();
Toast.makeText(LoginActivity.this, "Login success !", Toast.LENGTH_SHORT).show();
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
SendUserToPhotoActivity(phone, uid);
}
});
} else {
String message = task.getException().toString();
Toast.makeText(LoginActivity.this, "Error:" + message, Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
}
}
});
public class MainActivity extends AppCompatActivity {
EditText editTextPhone, editTextCode;
FirebaseAuth mAuth;
String codeSent;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAuth = FirebaseAuth.getInstance();
editTextCode = findViewById(R.id.editTextCode);
editTextPhone = findViewById(R.id.editTextPhone);
findViewById(R.id.buttonGetVerificationCode).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
sendVerificationCode();
}
});
findViewById(R.id.buttonSignIn).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
verifySignInCode();
}
});
}
private void verifySignInCode(){
String code = editTextCode.getText().toString();
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(codeSent, code);
signInWithPhoneAuthCredential(credential);
}
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
//here you can open new activity
Toast.makeText(getApplicationContext(),
"Login Successfull", Toast.LENGTH_LONG).show();
} else {
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
Toast.makeText(getApplicationContext(),
"Incorrect Verification Code ", Toast.LENGTH_LONG).show();
}
}
}
});
}
private void sendVerificationCode(){
String phone = editTextPhone.getText().toString();
if(phone.isEmpty()){
editTextPhone.setError("Phone number is required");
editTextPhone.requestFocus();
return;
}
if(phone.length() < 10 ){
editTextPhone.setError("Please enter a valid phone");
editTextPhone.requestFocus();
return;
}
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phone, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks); // OnVerificationStateChangedCallbacks
}
PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
}
#Override
public void onVerificationFailed(FirebaseException e) {
}
#Override
public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(s, forceResendingToken);
codeSent = s;
}
};
}
Firebase not sending a auth code to mobile for verification please check what is the problem
because if your already regiter a number then 2nd time doesnot send if you want to try them to get otp then delete a number from firebase auth and try again
I want to add mobile number verification module in my application. I am using firebase for this and OTP is getting successfully sent to the particular mobile number but I want to validate whether the OTP entered is equal to the OTP sent to the respective mobile number.
I don't want to use the following code,
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Toast.makeText(FirebasePhoneActivity.this, "Verification Success", Toast.LENGTH_SHORT).show();
} else {
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
Toast.makeText(FirebasePhoneActivity.this, "Verification Failed, Invalid credentials", Toast.LENGTH_SHORT).show();
}
}
}
});
break;
because using the above code lets the user Sign-In using mobile number. I want only to cross verify the OTP and don't want to Sign-In using MOBILE NUMBER.
#Override
public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(s, forceResendingToken);
codeSent = s;
resendToken = forceResendingToken;
}
Using the above code doesn't give the code that's sent but a random string value.
PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
codeReceivedByUser = phoneAuthCredential.getSmsCode();
}
The above code is getting called only when the OTP is received to his mobile and not in someone else's mobile(case when we give other person's mobile number)
Is there any way to validate the OTP when sent to someone else's mobile without using signInWithCredential method? Kindly help. Thanks in advance.
Try below code(call method one by one)
private void setListener() {
callbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
Toast.makeText(context, "Verification Completed" + phoneAuthCredential, Toast.LENGTH_SHORT).show();
}
#Override
public void onVerificationFailed(FirebaseException e) {
try {
ActivityHelper.dismissProgressDialog();
} catch (Throwable throwable) {
CustomLogHandler.printErrorlog(throwable);
}
if (e instanceof FirebaseAuthInvalidCredentialsException) {
Toast.makeText(context ,"Verification Failed" + e, Toast.LENGTH_SHORT).show();
} else if (e instanceof FirebaseTooManyRequestsException) {
Toast.makeText(context, "Verification Failed" + e, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(context, "Verification Failed" + e, Toast.LENGTH_SHORT).show();
}
isResendClicked = false;
}
#Override
public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(s, forceResendingToken);
try {
ActivityHelper.dismissProgressDialog();
} catch (Throwable throwable) {
CustomLogHandler.printErrorlog(throwable);
}
Toast.makeText(getActivity(), "Code sent to your registered device", Toast.LENGTH_SHORT).show();
isResendClicked = false;
verificationId = s;
resendtoken = forceResendingToken;
}
};
}
private void callGetOTPApi() {
try {
ActivityHelper.showProgressDialog(getActivity(), "Loading...", false);
PhoneAuthProvider.getInstance().verifyPhoneNumber(number, 60, TimeUnit.SECONDS, getActivity(), callbacks);
} catch (Throwable throwable) {
CustomLogHandler.printErrorlog(throwable);
}
}
I am new to Android development. I am not getting OTP message from Fire base but if I enter the code manually then it works. I am not sure why I am not getting text message. Your help is highly appreciated. I am not sure whether I am doing correctly sendVerificationcode method correctly or not.
Steps Completed:
1) I added GSON file to app directory
2) I added test phone number in the firebase console
3) I added SHA1 code to fire base
4) I added SMS permission in the Android manifest file.
5) I enabled firebase authentication in Android studio
6) I tried different phone numbers too
VerifyPhoneActivity.java
public class VerifyPhoneActivity extends AppCompatActivity {
private String verificationId;
private FirebaseAuth mAuth;
private ProgressBar progressBar;
private EditText editText;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_verify_phone);
mAuth = FirebaseAuth.getInstance();
progressBar = findViewById(R.id.progressbar);
editText = findViewById(R.id.editTextCode);
String phonenumber = getIntent().getStringExtra("phonenumber");
sendVerificationCode(phonenumber);
findViewById(R.id.buttonSignIn).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String code = editText.getText().toString().trim();
if (code.isEmpty() || code.length() < 6) {
editText.setError("Enter code...");
editText.requestFocus();
return;
}
verifyCode(code);
}
});
}
private void verifyCode(String code) {
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
signInWithCredential(credential);
}
private void signInWithCredential(PhoneAuthCredential credential) {
// private void signInWithCredential(PhoneAuthCredential) {
mAuth.signInWithCredential(credential)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Intent intent = new Intent(VerifyPhoneActivity.this, ProfileActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
} else {
Toast.makeText(VerifyPhoneActivity.this, task.getException().getMessage(), Toast.LENGTH_LONG).show();
}
}
});
}
private void sendVerificationCode(String number) {
progressBar.setVisibility(View.VISIBLE);
PhoneAuthProvider.getInstance().verifyPhoneNumber(
number,
60,
TimeUnit.SECONDS,
TaskExecutors.MAIN_THREAD,
mCallBack
);
}
private PhoneAuthProvider.OnVerificationStateChangedCallbacks
mCallBack = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(s, forceResendingToken);
verificationId = s;
}
#Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
String code = phoneAuthCredential.getSmsCode();
if (code != null) {
editText.setText(code);
verifyCode(code);
}
System.out.println("Hello Phone Number"+code);
}
#Override
public void onVerificationFailed(FirebaseException e) {
Toast.makeText(VerifyPhoneActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
}
};
}
Below code looks like not working:
#Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
String code = phoneAuthCredential.getSmsCode();
// String code="000000";
if (code != null) {
editText.setText(code);
verifyCode(code);
}
System.out.println("Hello Phone Number2"+code);
}
Use like this following:
onCreate
mAuth = FirebaseAuth.getInstance();
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks()
{
#Override
public void onVerificationCompleted(PhoneAuthCredential credential)
{
// This callback will be invoked in two situations:
// 1 - Instant verification. In some cases the phone number can be instantly
// verified without needing to send or enter a verification code.
// 2 - Auto-retrieval. On some devices Google Play services can automatically
// detect the incoming verification SMS and perform verificaiton without
// user action.
Log.d(TAG, "onVerificationCompleted:" + credential);
Log.e("number","credential=-=-=>>><<>>>signInWithPhoneAuthCredential-->>");
signInWithPhoneAuthCredential(credential);
}
#Override
public void onVerificationFailed(FirebaseException e)
{
// This callback is invoked in an invalid request for verification is made,
// for instance if the the phone number format is not valid.
Log.e(TAG, "onVerificationFailed", e);
// Show a message and update the UI
// ...
}
#Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token)
{
// The SMS verification code has been sent to the provided phone number, we
// now need to ask the user to enter the code and then construct a credential
// by combining the code with a verification ID.
Log.e(TAG, "onCodeSent:" + verificationId+"<<token>>"+token);
// Save verification ID and resending token so we can use them later
mVerificationId = verificationId;
//mResendToken = token;
// ...
}
};
//String phoneNumber=Settings.PREFIX + Settings.PREFIX_PHONE;
String phoneNumber="your phone number with prefix";
Log.e("number","credential=-=-=>>>22222>>"+phoneNumber);
if(phoneNumber!=null && !phoneNumber.isEmpty())
{
startPhoneNumberVerification(phoneNumber);
}
Method:
private void startPhoneNumberVerification(String phoneNumber)
{
Log.e("startPhoneNumber","startPhoneNumberVerification------>>"+phoneNumber);
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks); // OnVerificationStateChangedCallbacks
Log.e("startPhoneNumber","startPhoneNumberVerification--2222222---->>"+phoneNumber);
}
Method:
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential)
{
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>()
{
#Override
public void onComplete(#NonNull Task<AuthResult> task)
{
if (task.isSuccessful())
{
// Sign in success, update UI with the signed-in user's information
Log.e(TAG, "signInWithCredential:success");
} else
{
// Sign in failed, display a message and update the UI
Log.e(TAG, "signInWithCredential:failure", task.getException());
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException)
{
}
}
}
});
}
private void verifyphone(final String phone)
{
final String ph=phone;
pDialog=new Dialog(this);
pDialog.setContentView(R.layout.phoneverification);
pDialog.setCancelable(true);
pcode=pDialog.findViewById(R.id.pcodebtn);
vcode=pDialog.findViewById(R.id.vcode);
pstatus=pDialog.findViewById(R.id.pstatus);
pDialog.show();
PhoneAuthProvider.getInstance().verifyPhoneNumber(phone, 30, TimeUnit.SECONDS, this, new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
#Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
pc=phoneAuthCredential;
continueemail();
}
#Override
public void onVerificationFailed(FirebaseException e) {
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
// ...
Toast.makeText(HomePage.this, "Invalid Phone number.Reenter correct phone number.", Toast.LENGTH_SHORT).show();
pDialog.dismiss();
wrongnumber=true;
Toast.makeText(HomePage.this, "Registration Failed", Toast.LENGTH_SHORT).show();
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// ...
Toast.makeText(HomePage.this, "SMS Quota exceeded.This is an internal error.", Toast.LENGTH_SHORT).show();
}
Toast.makeText(HomePage.this, "Registration Failed", Toast.LENGTH_SHORT).show();
}
#Override
public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(s, forceResendingToken);
Toast.makeText(HomePage.this, "Verification Code sent to the phone number", Toast.LENGTH_SHORT).show();
pstatus.setText("Verification Code has been sent to "+ph+".Please check phone and enter code to continue.");
pvercode=s;
mtoken=forceResendingToken;
}
});
pcode.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (TextUtils.isEmpty(vcode.getText().toString())) {
vcode.setError("Verification Code cannot empty");
} else if (vcode.getText().toString().length() != 6) {
vcode.setError("Verification code format is wrong");
}
else
{
if(PhoneAuthProvider.getCredential(pvercode,vcode.getText().toString())!=null)
{
pverified=true;
continueemail();
}
else
{
pverified=false;
pstatus.setText("Verification was unsuccessful.You entered wrong code!");
vcode.setError("Wrong Verification code was entered.");
Toast.makeText(HomePage.this, "Registration Failed,Pverified="+pverified, Toast.LENGTH_SHORT).show();
}
}
}
});
if(wrongnumber)
{
pverified=false;
}
if(pverified) {
pDialog.dismiss();
}
}
public void continueemail()
{
pDialog.dismiss();
mauth=FirebaseAuth.getInstance();
mauth.createUserWithEmailAndPassword(rmail.getText().toString(), rpass.getText().toString()).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
user = mauth.getCurrentUser();
user.sendEmailVerification().addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(HomePage.this, "We have sent you an email verification.", Toast.LENGTH_SHORT).show();
}
}
});
Toast.makeText(HomePage.this, "Registration sucessful", Toast.LENGTH_SHORT).show();
myDialog.dismiss();
}
else
{
rmail.setError("Enter a correct mailID we will be sending a verification mail.");
Toast.makeText(HomePage.this, "Wrong EmailID"+rmail.getText().toString(), Toast.LENGTH_SHORT).show();
}
}
});
}
}
I am able to complete phone authentication. But it always says email ID is not valid(i.e task.issuccessful()method is returning false always).I am not able to figure out why this is happening. Please help me out. Is it possible to authenticate both phone and email verification. Do I need to sign-out or something before I try to verify email after I verified phone number?