Last active
June 20, 2019 11:59
-
-
Save ardakazanci/aaa54ff80e50fb3c814a455fbd2b2d40 to your computer and use it in GitHub Desktop.
Emulator - Firebase Phone Auth Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun testPhoneVerify() { | |
// Beyaz Listeye eklenen telefon numarası | |
val phoneNum = "+16505554567" | |
val testVerificationCode = "123456" | |
// Whenever verification is triggered with the whitelisted number, | |
// provided it is not set for auto-retrieval, onCodeSent will be triggered. | |
PhoneAuthProvider.getInstance().verifyPhoneNumber( | |
phoneNum, 30L /*timeout*/, TimeUnit.SECONDS, | |
this, object : PhoneAuthProvider.OnVerificationStateChangedCallbacks() { | |
override fun onCodeSent( | |
verificationId: String?, | |
forceResendingToken: PhoneAuthProvider.ForceResendingToken? | |
) { | |
// Save the verification id somewhere | |
// ... | |
// The corresponding whitelisted code above should be used to complete sign-in. | |
this@MainActivity.enableUserManuallyInputCode() | |
} | |
override fun onVerificationCompleted(phoneAuthCredential: PhoneAuthCredential) { | |
// Sign in with the credential | |
// ... | |
} | |
override fun onVerificationFailed(e: FirebaseException) { | |
// ... | |
} | |
}) | |
// [END auth_test_phone_verify] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment