Advertisement
mahendrarajdhami

Mobile Authentication

May 19th, 2019
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  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.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement