Skip to content

Instantly share code, notes, and snippets.

@ardakazanci
Last active June 20, 2019 11:59
Show Gist options
  • Save ardakazanci/aaa54ff80e50fb3c814a455fbd2b2d40 to your computer and use it in GitHub Desktop.
Save ardakazanci/aaa54ff80e50fb3c814a455fbd2b2d40 to your computer and use it in GitHub Desktop.
Emulator - Firebase Phone Auth Snippets
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