fayaz07 / flutter_firebase

Implementing features of firebase with flutter
92 stars 67 forks source link

how to implement _signInWithPhoneNumber #3

Closed geekz-reno closed 4 years ago

geekz-reno commented 4 years ago

Hi, thank for sharing, can you give an example how to implement manual verification after entered pin?

fayaz07 commented 4 years ago

Hi @geekz-reno, head over to this file and look at line number 150, add a button there onclick-> call this method below, you can find this method in file

static void signInWithPhoneNumber(String smsCode) async {
    _authCredential = PhoneAuthProvider.getCredential(
        verificationId: actualCode, smsCode: smsCode);

    firebaseAuth
        .signInWithCredential(_authCredential)
        .then((FirebaseUser user) async {
      addStatus('Authentication successful');
      addState(PhoneAuthState.Verified);
      onAuthenticationSuccessful();
    }).catchError((error) {
      addState(PhoneAuthState.Error);
      addStatus('Something has gone wrong, please try later(signInWithPhoneNumber) $error');
    });
  }