I want,
If the user is new to the app, I want to create an account for the user with a name, profile picture, and bio.
How do I know is the user is registered or not? (Look at the screenshot) -
**I do below steps understand to user already have an account or not **
//phoneNumber: entered by user
if (phoneNumber ==
FirebaseFirestore.instance
.collection('users')
.doc('phoneNumber')) {
print("user have!!!! Show main screen");
} else {
print('no, register! get data.. textfiledssss........');
}
But the problem is, this is not working. always output no, register! get data.. textfiledssss........
There is screenshot of my firebase firestore database,
,
My steps are not good? (what I do for understanding to the user is alredy have an account or not) If there has another way to do this. please explain it. If my steps are ok, why did this happen?
You can query the user's phone number to check if the phone number is available in the firestore or not.
FirebaseFirestore.instance
.collection('users')
.where('phoneNumber', isEqualTo: phoneNumber)
.get()
.then((value) {
if (value.docs.isEmpty) {
print('no, register! get data.. textfiledssss........');
} else {
print("user have!!!! Show main screen");
}
});