How to do Phone Authentication in Flutter using Firebase?

前端 未结 6 1655
刺人心
刺人心 2021-02-02 02:27

I have searched many websites and I didn\'t find a way to implement phone authentication in Flutter using Firebase. Can anyone tell me how to this?

6条回答
  •  礼貌的吻别
    2021-02-02 03:04

    Currently _signInPhoneNumber is deprecated, so use this:

    try {
        AuthCredentialauthCredential = PhoneAuthProvider.getCredential(verificationId: verificationId, verificationsCode: smsCode);
    
        await _firebaseAuth
          .signInWithCredential(authCredential)
          .then((FirebaseUser user) async {
             final FirebaseUser currentUser = await _firebaseAuth.currentUser();
             assert(user.uid == currentUser.uid);
             print('signed in with phone number successful: user -> $user');
        }
    }
    

提交回复
热议问题