Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PhoneAuthProvider.getInstance().verifyPhoneNumber(
- phoneNumber, // Phone number to verify
- 60, // Timeout duration
- TimeUnit.SECONDS, // Unit of timeout
- this, // Activity (for callback binding)
- new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
- @Override
- public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
- if(notAutoRetrieval) {
- //firebase send otp to the given phone number
- }else{
- //firebase does send otp to the given phone number
- }
- }
- @Override
- public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
- super.onCodeSent(s, forceResendingToken);
- // 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.
- // if firebase send otp this method is execute
- notAutoRetrieval=true;
- }
- @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.
- if (e instanceof FirebaseAuthInvalidCredentialsException) {
- // Invalid request
- Toast.makeText(LogIn.this,e.getLocalizedMessage(),Toast.LENGTH_LONG).show();
- } else if (e instanceof FirebaseTooManyRequestsException) {
- // The SMS quota for the project has been exceeded
- }else{
- Toast.makeText(LogIn.this,e.getMessage(),Toast.LENGTH_LONG).show();
- }
- }
- });
Add Comment
Please, Sign In to add comment