在发送otp之前如何检查用户是否已经使用电话号码注册

时间:2019-05-07 06:33:48

标签: react-native google-cloud-firestore

检查电话号码是否存在(如果存在错误)并在otp之前检查

 signIn() {
this.setState({ waiting: true });
firebase
  .auth()
  .signInWithPhoneNumber(this.state.phoneNumber)
  //if phone number is right, then update phone in store and call verify code screen
  .then(res => {
    Store.currentUserPhone = this.state.phoneNumber;
    Actions.VerifyCode({ result: res });
  })
  .catch(error => this.setState({ error: error.message, waiting: false 
 }));
}

1 个答案:

答案 0 :(得分:0)

您可以使用

检查用户身份验证对象是否有phoneNumber值
const userAuth = firebase.auth().currentUser;
if(userAuth.phoneNumber !== undefined) {
   //user has phone number 
}else {
   //user does not have phone number
}