invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.69k stars 2.21k forks source link

How to confirm the received SMS code, after verifying a number? #2266

Closed ghost closed 5 years ago

ghost commented 5 years ago

firebase.auth().signInWithPhoneNumber(phoneNumber) returns a confirmation result, which allows us to confrim the SMS code, has received.

As like as below code:

firebase.auth().signInWithPhoneNumber(phoneNumber).then(confrimResult=>{
    confrimResult.confirm(code).then(user=>{
         if(user) console.log('SMS confirmed'); 
    });
});

And now is there a way to confirm the SMS code, which has received by firebase.auth().verifyPhoneNumber(phoneNumber)?

NarekChang commented 5 years ago

@muhammadwfa For example:

class Example extends React.Component{
  ...

  confirmResult = null

  sendCode = async (phoneNumber) => {
    try {
      const confirm = await auth().signInWithPhoneNumber(phoneNumber);
      this.confirmResult = confirm;

    } catch (err) {
      console.log(err)
    }
  }

  checkCode = async (code) => {
    try {
      const res = await this.confirmResult.confirm(code);
      console.log(res)
      const { _user, _auth } = res;
      console.log(_user, _auth)
    } catch (err) {
      console.log(err)
    }
  }

  ...
}
stale[bot] commented 5 years ago

Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.