Skip to content Skip to sidebar Skip to footer

Check If User Exists In Firestore

I'd like to create a users database in Cloud Firestore, with the email as the unique ID for each user. The users should be in a collection, and each user is a document. This is ho

Solution 1:

The result of this Task is a DocumentSnapshot. Whether or not the underlying document actually exists is available via the exists method.

If the document does exist you can call getData to get at the contents of it.

Solution 2:

Task result has a field named AdditionalUserInfo, you can find here isNewUser. it will return false if the user already exists.

  if (task.result?.additionalUserInfo!!.isNewUser){
         addNewUser()
    } else {
         updateUser()
  }

Post a Comment for "Check If User Exists In Firestore"