Skip to content

Instantly share code, notes, and snippets.

@guilhermecarvalhocarneiro
Created October 12, 2021 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhermecarvalhocarneiro/c40696d59c0bfcfc0f98c0533c5dfc5a to your computer and use it in GitHub Desktop.
Save guilhermecarvalhocarneiro/c40696d59c0bfcfc0f98c0533c5dfc5a to your computer and use it in GitHub Desktop.
await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber: phoneNumber,
verificationCompleted: (PhoneAuthCredential credential) async {
// ! Este método não é chamado
print("*******************************************************************");
print("Usuário registrado com sucesso");
print(credential.toString());
print("*******************************************************************");
final userAuth = await firebaseAuth.signInWithCredential(credential);
if (userAuth != null) {
print("USUÁRIO AUTENTICADO APÓS CONCLUIR A VALIDAÇÃO DO LOGIN NO FIREBASE");
_firebaseID = userAuth.user.uid;
print(_firebaseID);
}
},
// Callback disparado quando ocorre algum erro no Firebase
verificationFailed: (FirebaseAuthException e) {
_showMessage("Ocorreu um erro ao tentar registrar a conta, por favor tente novamente.", error: true);
_hideLoadingModal();
},
// Callback chamado quando o Firebase retorna o código baseado no número informado pelo usuário
// deve ser utilizado para atualizar a tela seguindo as regras de negócio do projeto
codeSent: (String verificationID, int resendToken) {
// ! Este método é chamado corretamente
setState(() {
_inputCodeConfirmationOTP = true;
_verificationID = verificationID;
});
},
// Callback chamado quando o timeout informado abaixo expirar
codeAutoRetrievalTimeout: (String verificationID) {
DebugPrint.print("Verification ID: $verificationID");
},
timeout: Duration(seconds: 120));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment