Firebase phone authentications flow
up vote
1
down vote
favorite
I am little bit confused about the right flow of the phone authentication.
I have noticed there is couple of scenarios that I cannot reproduce due to reason I can not completely delete my user from Firebase and reproduce all scenarios. The possible scenarios are:
- User never logged in to firebase
- User previously logged in and signed out, and on sign in receives SMS
- User previously logged in and signed out, and on sign in not receiving SMS
What happens for me is scenario 2. My log for this is:
D/DTAG: Asking verification for: +972052*****77
D/DTAG: 2. Sending for verification and waiting response to callbacks
D/DTAG: 3.b. Sending code
D/DTAG: 3.a. Verification complete, signing in
D/DTAG: signInWithCredential:success
Question 1: So now the SMS is irrelevant, right? I can login without checking the SMS code?
Question 2: At scenario 1, does callback "onVerificationCompleted" not called at all?
Question 3: At scenario 3, the callback "onCodeSent" not called at all?
Question 4: How can I retrieve the SMS code at "onCodeSent"?. I know I can at "onVerificationCompleted" to use phoneAuthCredential.getSmsCode(), but there are scenarios when it not called.
My code:
public class MyVerifyPhoneActivity extends AppCompatActivity {
private static final String TAG = "DTAG";
EditText editTextCode;
Button buttonLogin;
String mVerificationId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_verify_phone);
editTextCode = findViewById(R.id.editTextCode);
buttonLogin = findViewById(R.id.myButtonSignIn);
String phonenumber = getIntent().getStringExtra("phonenumber");
Log.d(TAG,"Asking verification for: "+phonenumber);
sendVerificationCode(phonenumber);
buttonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String code = editTextCode.getText().toString().trim();
Log.d(TAG,"Button login clicked");
if (code.isEmpty() || code.length() < 6) {
editTextCode.setError("Enter code...");
editTextCode.requestFocus();
return;
}
verifyCode(code);
}
});
}
private void sendVerificationCode(String number) {
Log.d(TAG,"2. Sending for verification and waiting response to callbacks");
PhoneAuthProvider.getInstance().verifyPhoneNumber(
number,
60,
TimeUnit.SECONDS,
TaskExecutors.MAIN_THREAD,
mCallBack
);
}
private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallBack = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
Log.d(TAG,"3.a. Verification complete, signing in");
signInWithPhoneAuthCredential(phoneAuthCredential);
}
@Override
public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(verificationId, forceResendingToken);
mVerificationId = verificationId;
Log.d(TAG,"3.b. Sending code");
}
@Override
public void onVerificationFailed(FirebaseException e) {
Log.w(TAG, "onVerificationFailed", e);
Log.d(TAG,"3.c. Failed");
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
// ...
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// ...
}
}
};
private void verifyCode(String code)
{
Log.d(TAG,"verifying Code");
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, code);
signInWithPhoneAuthCredential(credential);
}
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
FirebaseAuth.getInstance().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.d("DTAG", "signInWithCredential:success");
FirebaseUser user = task.getResult().getUser();
} else {
// Sign in failed, display a message and update the UI
Log.w("DTAG", "signInWithCredential:failure", task.getException());
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
// The verification code entered was invalid
}
}
}
});
}
}
android firebase firebase-authentication
add a comment |
up vote
1
down vote
favorite
I am little bit confused about the right flow of the phone authentication.
I have noticed there is couple of scenarios that I cannot reproduce due to reason I can not completely delete my user from Firebase and reproduce all scenarios. The possible scenarios are:
- User never logged in to firebase
- User previously logged in and signed out, and on sign in receives SMS
- User previously logged in and signed out, and on sign in not receiving SMS
What happens for me is scenario 2. My log for this is:
D/DTAG: Asking verification for: +972052*****77
D/DTAG: 2. Sending for verification and waiting response to callbacks
D/DTAG: 3.b. Sending code
D/DTAG: 3.a. Verification complete, signing in
D/DTAG: signInWithCredential:success
Question 1: So now the SMS is irrelevant, right? I can login without checking the SMS code?
Question 2: At scenario 1, does callback "onVerificationCompleted" not called at all?
Question 3: At scenario 3, the callback "onCodeSent" not called at all?
Question 4: How can I retrieve the SMS code at "onCodeSent"?. I know I can at "onVerificationCompleted" to use phoneAuthCredential.getSmsCode(), but there are scenarios when it not called.
My code:
public class MyVerifyPhoneActivity extends AppCompatActivity {
private static final String TAG = "DTAG";
EditText editTextCode;
Button buttonLogin;
String mVerificationId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_verify_phone);
editTextCode = findViewById(R.id.editTextCode);
buttonLogin = findViewById(R.id.myButtonSignIn);
String phonenumber = getIntent().getStringExtra("phonenumber");
Log.d(TAG,"Asking verification for: "+phonenumber);
sendVerificationCode(phonenumber);
buttonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String code = editTextCode.getText().toString().trim();
Log.d(TAG,"Button login clicked");
if (code.isEmpty() || code.length() < 6) {
editTextCode.setError("Enter code...");
editTextCode.requestFocus();
return;
}
verifyCode(code);
}
});
}
private void sendVerificationCode(String number) {
Log.d(TAG,"2. Sending for verification and waiting response to callbacks");
PhoneAuthProvider.getInstance().verifyPhoneNumber(
number,
60,
TimeUnit.SECONDS,
TaskExecutors.MAIN_THREAD,
mCallBack
);
}
private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallBack = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
Log.d(TAG,"3.a. Verification complete, signing in");
signInWithPhoneAuthCredential(phoneAuthCredential);
}
@Override
public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(verificationId, forceResendingToken);
mVerificationId = verificationId;
Log.d(TAG,"3.b. Sending code");
}
@Override
public void onVerificationFailed(FirebaseException e) {
Log.w(TAG, "onVerificationFailed", e);
Log.d(TAG,"3.c. Failed");
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
// ...
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// ...
}
}
};
private void verifyCode(String code)
{
Log.d(TAG,"verifying Code");
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, code);
signInWithPhoneAuthCredential(credential);
}
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
FirebaseAuth.getInstance().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.d("DTAG", "signInWithCredential:success");
FirebaseUser user = task.getResult().getUser();
} else {
// Sign in failed, display a message and update the UI
Log.w("DTAG", "signInWithCredential:failure", task.getException());
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
// The verification code entered was invalid
}
}
}
});
}
}
android firebase firebase-authentication
code is only sent when number you're verifying isn't in the same phone.
– Ali Ahmed
Nov 12 at 9:09
This not the case for me, after some testing from using phone B with number of phone A, now I receive the code every time on phone A and using phone A.
– Dim
Nov 12 at 9:12
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am little bit confused about the right flow of the phone authentication.
I have noticed there is couple of scenarios that I cannot reproduce due to reason I can not completely delete my user from Firebase and reproduce all scenarios. The possible scenarios are:
- User never logged in to firebase
- User previously logged in and signed out, and on sign in receives SMS
- User previously logged in and signed out, and on sign in not receiving SMS
What happens for me is scenario 2. My log for this is:
D/DTAG: Asking verification for: +972052*****77
D/DTAG: 2. Sending for verification and waiting response to callbacks
D/DTAG: 3.b. Sending code
D/DTAG: 3.a. Verification complete, signing in
D/DTAG: signInWithCredential:success
Question 1: So now the SMS is irrelevant, right? I can login without checking the SMS code?
Question 2: At scenario 1, does callback "onVerificationCompleted" not called at all?
Question 3: At scenario 3, the callback "onCodeSent" not called at all?
Question 4: How can I retrieve the SMS code at "onCodeSent"?. I know I can at "onVerificationCompleted" to use phoneAuthCredential.getSmsCode(), but there are scenarios when it not called.
My code:
public class MyVerifyPhoneActivity extends AppCompatActivity {
private static final String TAG = "DTAG";
EditText editTextCode;
Button buttonLogin;
String mVerificationId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_verify_phone);
editTextCode = findViewById(R.id.editTextCode);
buttonLogin = findViewById(R.id.myButtonSignIn);
String phonenumber = getIntent().getStringExtra("phonenumber");
Log.d(TAG,"Asking verification for: "+phonenumber);
sendVerificationCode(phonenumber);
buttonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String code = editTextCode.getText().toString().trim();
Log.d(TAG,"Button login clicked");
if (code.isEmpty() || code.length() < 6) {
editTextCode.setError("Enter code...");
editTextCode.requestFocus();
return;
}
verifyCode(code);
}
});
}
private void sendVerificationCode(String number) {
Log.d(TAG,"2. Sending for verification and waiting response to callbacks");
PhoneAuthProvider.getInstance().verifyPhoneNumber(
number,
60,
TimeUnit.SECONDS,
TaskExecutors.MAIN_THREAD,
mCallBack
);
}
private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallBack = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
Log.d(TAG,"3.a. Verification complete, signing in");
signInWithPhoneAuthCredential(phoneAuthCredential);
}
@Override
public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(verificationId, forceResendingToken);
mVerificationId = verificationId;
Log.d(TAG,"3.b. Sending code");
}
@Override
public void onVerificationFailed(FirebaseException e) {
Log.w(TAG, "onVerificationFailed", e);
Log.d(TAG,"3.c. Failed");
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
// ...
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// ...
}
}
};
private void verifyCode(String code)
{
Log.d(TAG,"verifying Code");
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, code);
signInWithPhoneAuthCredential(credential);
}
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
FirebaseAuth.getInstance().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.d("DTAG", "signInWithCredential:success");
FirebaseUser user = task.getResult().getUser();
} else {
// Sign in failed, display a message and update the UI
Log.w("DTAG", "signInWithCredential:failure", task.getException());
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
// The verification code entered was invalid
}
}
}
});
}
}
android firebase firebase-authentication
I am little bit confused about the right flow of the phone authentication.
I have noticed there is couple of scenarios that I cannot reproduce due to reason I can not completely delete my user from Firebase and reproduce all scenarios. The possible scenarios are:
- User never logged in to firebase
- User previously logged in and signed out, and on sign in receives SMS
- User previously logged in and signed out, and on sign in not receiving SMS
What happens for me is scenario 2. My log for this is:
D/DTAG: Asking verification for: +972052*****77
D/DTAG: 2. Sending for verification and waiting response to callbacks
D/DTAG: 3.b. Sending code
D/DTAG: 3.a. Verification complete, signing in
D/DTAG: signInWithCredential:success
Question 1: So now the SMS is irrelevant, right? I can login without checking the SMS code?
Question 2: At scenario 1, does callback "onVerificationCompleted" not called at all?
Question 3: At scenario 3, the callback "onCodeSent" not called at all?
Question 4: How can I retrieve the SMS code at "onCodeSent"?. I know I can at "onVerificationCompleted" to use phoneAuthCredential.getSmsCode(), but there are scenarios when it not called.
My code:
public class MyVerifyPhoneActivity extends AppCompatActivity {
private static final String TAG = "DTAG";
EditText editTextCode;
Button buttonLogin;
String mVerificationId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_verify_phone);
editTextCode = findViewById(R.id.editTextCode);
buttonLogin = findViewById(R.id.myButtonSignIn);
String phonenumber = getIntent().getStringExtra("phonenumber");
Log.d(TAG,"Asking verification for: "+phonenumber);
sendVerificationCode(phonenumber);
buttonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String code = editTextCode.getText().toString().trim();
Log.d(TAG,"Button login clicked");
if (code.isEmpty() || code.length() < 6) {
editTextCode.setError("Enter code...");
editTextCode.requestFocus();
return;
}
verifyCode(code);
}
});
}
private void sendVerificationCode(String number) {
Log.d(TAG,"2. Sending for verification and waiting response to callbacks");
PhoneAuthProvider.getInstance().verifyPhoneNumber(
number,
60,
TimeUnit.SECONDS,
TaskExecutors.MAIN_THREAD,
mCallBack
);
}
private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallBack = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
Log.d(TAG,"3.a. Verification complete, signing in");
signInWithPhoneAuthCredential(phoneAuthCredential);
}
@Override
public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(verificationId, forceResendingToken);
mVerificationId = verificationId;
Log.d(TAG,"3.b. Sending code");
}
@Override
public void onVerificationFailed(FirebaseException e) {
Log.w(TAG, "onVerificationFailed", e);
Log.d(TAG,"3.c. Failed");
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
// ...
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// ...
}
}
};
private void verifyCode(String code)
{
Log.d(TAG,"verifying Code");
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, code);
signInWithPhoneAuthCredential(credential);
}
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
FirebaseAuth.getInstance().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.d("DTAG", "signInWithCredential:success");
FirebaseUser user = task.getResult().getUser();
} else {
// Sign in failed, display a message and update the UI
Log.w("DTAG", "signInWithCredential:failure", task.getException());
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
// The verification code entered was invalid
}
}
}
});
}
}
android firebase firebase-authentication
android firebase firebase-authentication
edited Nov 12 at 10:48
droidBomb
55615
55615
asked Nov 12 at 9:02
Dim
1,06465494
1,06465494
code is only sent when number you're verifying isn't in the same phone.
– Ali Ahmed
Nov 12 at 9:09
This not the case for me, after some testing from using phone B with number of phone A, now I receive the code every time on phone A and using phone A.
– Dim
Nov 12 at 9:12
add a comment |
code is only sent when number you're verifying isn't in the same phone.
– Ali Ahmed
Nov 12 at 9:09
This not the case for me, after some testing from using phone B with number of phone A, now I receive the code every time on phone A and using phone A.
– Dim
Nov 12 at 9:12
code is only sent when number you're verifying isn't in the same phone.
– Ali Ahmed
Nov 12 at 9:09
code is only sent when number you're verifying isn't in the same phone.
– Ali Ahmed
Nov 12 at 9:09
This not the case for me, after some testing from using phone B with number of phone A, now I receive the code every time on phone A and using phone A.
– Dim
Nov 12 at 9:12
This not the case for me, after some testing from using phone B with number of phone A, now I receive the code every time on phone A and using phone A.
– Dim
Nov 12 at 9:12
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
I cannot reproduce due to reason I can not completely delete my user from Firebase
-> Yes you can. have a look at image.
Answer of Question 1:
-> It is not. SMS is obviously relevant. without SMS, phone-authentication will not work.
Answer of Question 2:
-> onVerificationCompleted
will be called every-time.
Answer of Question 3:
-> Yes. onCodeSent
is not being called every-time.
Answer of Question 4:
-> You do not need OTP in onCodeSent
method. We can get verificationId
and PhoneAuthProvider.ForceResendingToken
in onCodeSent.
we need to save verificationId
in a variable. and use it while authentication user entered OTP.
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, YouEditTextValueString);
My opinion:
I had also these questions in my mind when I worked first time on it. I experienced that if we use same device with same phone-number, SMS is not coming and I guess Firebase
or google-play-service
handle it.
Somehow right-now I am receiving SMS every time for the same device and phone-number.
but we don't need to care about it.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258790%2ffirebase-phone-authentications-flow%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
I cannot reproduce due to reason I can not completely delete my user from Firebase
-> Yes you can. have a look at image.
Answer of Question 1:
-> It is not. SMS is obviously relevant. without SMS, phone-authentication will not work.
Answer of Question 2:
-> onVerificationCompleted
will be called every-time.
Answer of Question 3:
-> Yes. onCodeSent
is not being called every-time.
Answer of Question 4:
-> You do not need OTP in onCodeSent
method. We can get verificationId
and PhoneAuthProvider.ForceResendingToken
in onCodeSent.
we need to save verificationId
in a variable. and use it while authentication user entered OTP.
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, YouEditTextValueString);
My opinion:
I had also these questions in my mind when I worked first time on it. I experienced that if we use same device with same phone-number, SMS is not coming and I guess Firebase
or google-play-service
handle it.
Somehow right-now I am receiving SMS every time for the same device and phone-number.
but we don't need to care about it.
add a comment |
up vote
2
down vote
accepted
I cannot reproduce due to reason I can not completely delete my user from Firebase
-> Yes you can. have a look at image.
Answer of Question 1:
-> It is not. SMS is obviously relevant. without SMS, phone-authentication will not work.
Answer of Question 2:
-> onVerificationCompleted
will be called every-time.
Answer of Question 3:
-> Yes. onCodeSent
is not being called every-time.
Answer of Question 4:
-> You do not need OTP in onCodeSent
method. We can get verificationId
and PhoneAuthProvider.ForceResendingToken
in onCodeSent.
we need to save verificationId
in a variable. and use it while authentication user entered OTP.
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, YouEditTextValueString);
My opinion:
I had also these questions in my mind when I worked first time on it. I experienced that if we use same device with same phone-number, SMS is not coming and I guess Firebase
or google-play-service
handle it.
Somehow right-now I am receiving SMS every time for the same device and phone-number.
but we don't need to care about it.
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
I cannot reproduce due to reason I can not completely delete my user from Firebase
-> Yes you can. have a look at image.
Answer of Question 1:
-> It is not. SMS is obviously relevant. without SMS, phone-authentication will not work.
Answer of Question 2:
-> onVerificationCompleted
will be called every-time.
Answer of Question 3:
-> Yes. onCodeSent
is not being called every-time.
Answer of Question 4:
-> You do not need OTP in onCodeSent
method. We can get verificationId
and PhoneAuthProvider.ForceResendingToken
in onCodeSent.
we need to save verificationId
in a variable. and use it while authentication user entered OTP.
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, YouEditTextValueString);
My opinion:
I had also these questions in my mind when I worked first time on it. I experienced that if we use same device with same phone-number, SMS is not coming and I guess Firebase
or google-play-service
handle it.
Somehow right-now I am receiving SMS every time for the same device and phone-number.
but we don't need to care about it.
I cannot reproduce due to reason I can not completely delete my user from Firebase
-> Yes you can. have a look at image.
Answer of Question 1:
-> It is not. SMS is obviously relevant. without SMS, phone-authentication will not work.
Answer of Question 2:
-> onVerificationCompleted
will be called every-time.
Answer of Question 3:
-> Yes. onCodeSent
is not being called every-time.
Answer of Question 4:
-> You do not need OTP in onCodeSent
method. We can get verificationId
and PhoneAuthProvider.ForceResendingToken
in onCodeSent.
we need to save verificationId
in a variable. and use it while authentication user entered OTP.
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, YouEditTextValueString);
My opinion:
I had also these questions in my mind when I worked first time on it. I experienced that if we use same device with same phone-number, SMS is not coming and I guess Firebase
or google-play-service
handle it.
Somehow right-now I am receiving SMS every time for the same device and phone-number.
but we don't need to care about it.
edited Nov 22 at 11:29
answered Nov 22 at 11:12
Rumit Patel
1,47842134
1,47842134
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258790%2ffirebase-phone-authentications-flow%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
code is only sent when number you're verifying isn't in the same phone.
– Ali Ahmed
Nov 12 at 9:09
This not the case for me, after some testing from using phone B with number of phone A, now I receive the code every time on phone A and using phone A.
– Dim
Nov 12 at 9:12