Guest User

Untitled

a guest
Jun 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. PhoneAuthProvider.getInstance().verifyPhoneNumber(
  2. phoneNumber, // Phone number to verify
  3. 60, // Timeout duration
  4. TimeUnit.SECONDS, // Unit of timeout
  5. this, // Activity (for callback binding)
  6. new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
  7. @Override
  8. public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
  9.  
  10. if(notAutoRetrieval) {
  11.  
  12. //firebase send otp to the given phone number
  13.  
  14. }else{
  15. //firebase does send otp to the given phone number
  16. }
  17.  
  18. }
  19.  
  20. @Override
  21. public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
  22. super.onCodeSent(s, forceResendingToken);
  23.  
  24. // The SMS verification code has been sent to the provided phone number, we
  25. // now need to ask the user to enter the code and then construct a credential
  26. // by combining the code with a verification ID.
  27.  
  28. // if firebase send otp this method is execute
  29.  
  30.  
  31. notAutoRetrieval=true;
  32.  
  33. }
  34.  
  35. @Override
  36. public void onVerificationFailed(FirebaseException e) {
  37.  
  38. // This callback is invoked in an invalid request for verification is made,
  39. // for instance if the the phone number format is not valid.
  40.  
  41. if (e instanceof FirebaseAuthInvalidCredentialsException) {
  42. // Invalid request
  43. Toast.makeText(LogIn.this,e.getLocalizedMessage(),Toast.LENGTH_LONG).show();
  44.  
  45. } else if (e instanceof FirebaseTooManyRequestsException) {
  46. // The SMS quota for the project has been exceeded
  47.  
  48. }else{
  49. Toast.makeText(LogIn.this,e.getMessage(),Toast.LENGTH_LONG).show();
  50.  
  51. }
  52.  
  53.  
  54. }
  55. });
Add Comment
Please, Sign In to add comment