React Native Firebase - signInWithPhoneNumber not returning confirmationResult

Viewed 341

I'm using react-native-firebase for phone auth from firebase.

I'm following the documentation from https://rnfirebase.io/auth/phone-auth

    // Handle the button press
  async function signInWithPhoneNumber(phoneNumber) {
    // Unreachable code. The Promise doesn't return anything here
    const confirmation = await auth().signInWithPhoneNumber(phoneNumber);
    setConfirm(confirmation);
  }

  async function confirmCode() {
    try {
    // confirm object is null, as signInWithPhoneNumber didn't return the promise.
      await confirm.confirm(code);
    } catch (error) {
      console.log('Invalid code.');
    }
  } 
     

This code fires the SMS, and if the same phone has it, the verification happens in the behind function onAuthStateChanged(user) ( still without returning a promise in the above call )

I've tried debugging the native code, and found that in ReactNativeAuthModule.java - onCodeSent() is having a verificationId

Why is my react promise still unresolved? Only then I can do the manual verification of OTP by confirm.confirm(code);

Any help is appreciated.

Update : here is the adb logcat

2021-07-23 16:56:10.769 6249-6330/com.zing D/Auth: signInWithPhoneNumber
2021-07-23 16:56:13.410 6249-6283/com.zing W/System: Ignoring header X-Firebase-Locale because its value was null.
0 Answers
Related