SHARE
TWEET

Mobile Authentication

mahendrarajdhami May 19th, 2019 408 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. String phoneNum = "+16505554567";
  2. String testVerificationCode = "123456";
  3.  
  4. // Whenever verification is triggered with the whitelisted number,
  5. // provided it is not set for auto-retrieval, onCodeSent will be triggered.
  6. PhoneAuthProvider.getInstance().verifyPhoneNumber(
  7.         phoneNum, 30L /*timeout*/, TimeUnit.SECONDS,
  8.         this, new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
  9.  
  10.             @Override
  11.             public void onCodeSent(String verificationId,
  12.                                    PhoneAuthProvider.ForceResendingToken forceResendingToken) {
  13.                 // Save the verification id somewhere
  14.                 // ...
  15.  
  16.                 // The corresponding whitelisted code above should be used to complete sign-in.
  17.                 MainActivity.this.enableUserManuallyInputCode();
  18.             }
  19.  
  20.             @Override
  21.             public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
  22.                 // Sign in with the credential
  23.                 // ...
  24.             }
  25.  
  26.             @Override
  27.             public void onVerificationFailed(FirebaseException e) {
  28.                  // ...
  29.             }
  30.  
  31.         });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top