Mohamed Benattou
Mohamed Benattou

Reputation: 105

Saving user data to Firestore

In a Flutter android app, users should authentificate with Firebase Phone Authentification, so, what I can't do is to save user entered data to cloud firestore like name and phone number in a node named "users".

I can do it with EmailAndPassword Authentification like this :

final FirebaseUser user =
        (await firebaseAuth.createUserWithEmailAndPassword(
                email: _mailTextController.text.trim(),
                password: _passTextController.text.trim()))
            .user;
    firestore.collection('users').document(user.uid.toString()).setData({
      'nom': _nomTextController.text.trim(),
      'email': _mailTextController.text.trim(),
      'userID': user.uid.toString()
    });

Any help with PhoneAuthentification process

Upvotes: 0

Views: 518

Answers (1)

griffins
griffins

Reputation: 8246

you can save the user phone and number in a similar way as you saved user who signed up with email.

AFter phoneAuth is completed and successful you can get user id and write data to cloud firestore normally.

 firestore.collection('users').document(user.uid.).setData({
  'nom': _nomTextController.text.trim(),
  'name': _name.text,
  'userID': user.uid.toString()
});

you can see how to login with phone auth firebase here

Upvotes: 1

Related Questions