Reputation:
How to check if User has registrated before with their Phone Number on the client Side (Firebase Auth)? Im using Swift 5 and Xcode 10
Upvotes: 1
Views: 324
Reputation: 30798
You can't do that with the client SDK. An open API for looking up phone numbers in an app could have privacy implications.
However, you can build your own check via the Firebase Admin SDK:
admin.auth().getUserByPhoneNumber(phoneNumber)
.then(function(userRecord) {
// User with provided phone number is already registered.
})
.catch(function(error) {
// if error.code 'auth/user-not-found' thrown,
// then the user does not exist.
console.log('Error fetching user data:', error);
});
Upvotes: 2