capawesome-team / capacitor-firebase

⚡️ Firebase plugins for Capacitor. Supports Android, iOS and the Web.
https://capawesome.io/plugins/firebase/
Apache License 2.0
405 stars 102 forks source link

bug: phoneNumberSignin method is not working on release build #728

Closed ntflabsdev closed 2 weeks ago

ntflabsdev commented 1 month ago

Plugin(s)

Version

6.1.2

Platform(s)

Current behavior

when i run my project in debug mode this plugin works but when i make a release build this method did't giving me any response also i have added try catch but its not going in catch part .

Here is my code phoneNumberSignin(phoneNumber: string, recaptchaVerifier: firebase.auth.RecaptchaVerifier) { const verifyCode = new BehaviorSubject(false);

// Ensure the reCAPTCHA is rendered before calling signInWithPhoneNumber
recaptchaVerifier.render().then((widgetId) => {
  if (this.platform.is('ios') || this.platform.is('android')) {
    Bugsnag.notify(new Error('inside phone auth'))

    FirebaseAuthentication.signInWithPhoneNumber({
      phoneNumber,
      timeout: 3000,
    })
      .then(async () => {
        FirebaseAuthentication.addListener('phoneCodeSent', (res) => {
          Bugsnag.notify(new Error(`inside listener ${JSON.stringify(res)}`))
          this.verificationId = { verificationId: res.verificationId };
          verifyCode.next(true);
          verifyCode.complete();
        });
      })
      .catch((err) => {
        console.log('cordova phone auth error ....', err);
        Bugsnag.notify(new Error(`inside catch  ${err.message}`))
        verifyCode.next(false);
        this.notificationService.failure(err.message);
        verifyCode.complete();
      });
  } else {
    signInWithPhoneNumber(auth, phoneNumber, recaptchaVerifier)
      .then((res) => {
        this.verificationId = res;
        this.confirmationResult = res;
        //alert(`Verification code sent: ${res}`);
        verifyCode.next(true);
      })
      .catch((err) => {
        verifyCode.next(false);
        console.log('phone auth error ....', err);
        this.notificationService.failure(err.message);
      })
      .finally(() => {
        verifyCode.complete();
      });
  }
}).catch((err) => {
  console.log('reCAPTCHA rendering error: ', err);
  this.notificationService.failure(err.message);
});

return verifyCode.asObservable();

}

Expected behavior

it should works same as works on debug

Reproduction

https://github.com/capawesome-team/capacitor-firebase.git

Steps to reproduce

Run this code first on debug it will. and then make and release build and run it on your android device

Other information

No response

Capacitor doctor

npx cap doctor

[warn] The bundledWebRuntime configuration option has been deprecated. Can be safely deleted. 💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 6.1.2 @capacitor/core: 6.1.2 @capacitor/android: 6.1.2 @capacitor/ios: 6.1.2

Installed Dependencies:

@capacitor/cli: 5.7.8 @capacitor/android: 6.1.2 @capacitor/core: 6.1.2 @capacitor/ios: 5.7.8

[success] iOS looking great! 👌 [success] Android looking great! 👌

Before submitting

robingenz commented 1 month ago

This does not seem to be a problem with the plugin but with your build configuration. Without an error message (e.g. from Firebase Crashlytics) I can't help you any further (especially without reproduction).

ntflabsdev commented 1 month ago

This does not seem to be a problem with the plugin but with your build configuration. Without an error message (e.g. from Firebase Crashlytics) I can't help you any further (especially without reproduction).

when i am calling the FIrebaseAuthentication.signinwithPhoneNumber method then the listener doest give any response also it goes in then block and after that the listner doesn't work and also the app not crash it keeps on waiting the response from the listner.

here's my code pls check this

recaptchaVerifier.render().then((widgetId) => {
  if (this.platform.is('ios') || this.platform.is('android')) {
    Bugsnag.notify(new Error('inside phone auth'))

    FirebaseAuthentication.signInWithPhoneNumber({
      phoneNumber,
      timeout: 3000,
    })
      .then(async () => {
        FirebaseAuthentication.addListener('phoneCodeSent', (res) => {
          Bugsnag.notify(new Error(`inside listener ${JSON.stringify(res)}`))
          this.verificationId = { verificationId: res.verificationId };
          verifyCode.next(true);
          verifyCode.complete();
        });
      })
      .catch((err) => {
        console.log('cordova phone auth error ....', err);
        Bugsnag.notify(new Error(`inside catch  ${err.message}`))
        verifyCode.next(false);
        this.notificationService.failure(err.message);
        verifyCode.complete();
      });
robingenz commented 1 month ago

You need to add the listener before calling signInWithPhoneNumber.

ntflabsdev commented 1 month ago

You need to add the listener before calling signInWithPhoneNumber.

You need to add the listener before calling signInWithPhoneNumber.

but it works fine on debug, when i try relase apk the listner doesnt works

robingenz commented 1 month ago

You should fix it anyway. Apart from that, you only listen for the phoneCodeSent. You should also listen for the phoneVerificationFailed and phoneVerificationCompleted events.

github-actions[bot] commented 2 weeks ago

It looks like there hasn't been a reply in 30 days, so I'm closing this issue.