如何在客户端(Firebase Auth)上检查用户之前是否已注册其电话号码?我正在使用Swift 5和Xcode 10
您无法使用客户端SDK执行此操作。用于在应用程序中查找电话号码的开放式API可能会对隐私产生影响。
但是,您可以通过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);
});