NativeScript / firebase

Modular Firebase 🔥 implementation for NativeScript. Supports both iOS & Android platforms for all Firebase services.
https://docs.nativescript.org/plugins/firebase-core.html
Apache License 2.0
56 stars 50 forks source link

Displaying alert after canceling from firebase().ui().show() causes exception #233

Closed dlcole closed 8 months ago

dlcole commented 1 year ago

I’m using phone authentication in my javascript app:

let idp = await firebase().ui().show({ providers: [new PhoneProvider()] });

If I cancel out of the firebase UI and then display an alert, such as

} catch (e) {
      try {
        await dialogs.alert({
          title: "Log In",
          message: "Your login attempt failed; you will need to try again.\n\n" + e,
          okButtonText: "OK"
        });
      } catch (e) {
        console.log("login-page.onLoginTap alert error: " + e);
      }
}

I get an exception or crash. On Android, the exception is

android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@7dc810e is not valid; is your activity running?

Upon returning to the prior page, I can display alerts without error.

On iOS, there’s an immediate crash, even within a try/catch block.

I suspect this is more likely a firebase error than firebase-messaging plugin error, but is there any way guard against he exception/crash so that the app can continue and alert display? try/catch is not sufficient.

I'm using version 3.1.3 of the firebase plugins, and 8.5.9 of @nativescript/core.

triniwiz commented 9 months ago

Try wrapping the alert in the a timeout and lmk what happens.

dlcole commented 8 months ago

@triniwiz - thanks for the suggestion. I went back to look at this, and the problem no longer seems to exist.

On Android, the UI flow no longer allows for cancellation, so the use case isn't applicable.

On iOS, you still have to select the phone provider (even when it's the only provider to choose from), but that menu can be cancelled from successfully. All this is with version 3.2.0 of the firebase plugins, which I know are a little down-level.

I'll close this issue.