Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser screen is closed on android when application launched from background #60

Open
harishchopra86 opened this issue Feb 8, 2021 · 9 comments
Labels
discussion 🔥 Discussions about this plugin help wanted Extra attention is needed

Comments

@harishchopra86
Copy link

Which platform(s) does your issue occur on?

  • Android
  • Android version: 9
  • Both emulator and android phone

Please, provide the following version numbers that your issue occurs with:

  • CLI: 7.1.2
  • Cross-platform modules: 7.1.0
  • Runtime(s): tns-android: 7.0.1
  • Plugin(s): 3.0.2

Please, tell us how to recreate the issue in as much detail as possible.

I am using the plugin for opening a login url inside the application where user have to enter his credentials. During that process if user closes the application by pressing home button on android phone, and opens the app again by pressing app icon from phone menu, webview screen is automatically closed.
I wanted to know if is there a way to keep the webview login screen open when user opens the app by pressing app icon from phone menu.
I am using: android:launchMode="singleTask" in AndroidManifest.xml

Is there any code involved?

It can be reproduced in sample application

@jdnichollsc
Copy link
Member

Please check this comment: proyecto26/react-native-inappbrowser#153 (comment)
Let me know

@harishchopra86
Copy link
Author

@jdnichollsc Thanks for prompt response.

However it is still the same when application is launched from phone menu launcher icon and I get this error on console when application is launched from launcher icon:

JS: Unhandled Promise rejection: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object reference ; Zone: <root> ; Task: null ; Value: Error: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object reference createAlertDialog(file: node_modules/@nativescript/core/ui/dialogs/index.android.js:8:0)
JS:     at (file: node_modules/@nativescript/core/ui/dialogs/index.android.js:95:0)
JS:     at ZoneAwarePromise(file: node_modules/@nativescript/zone-js/zone-nativescript.js:902:0)
JS:     at alert(file: node_modules/@nativescript/core/ui/dialogs/index.android.js:92:0)
JS:     at openBrowser(file: src/app/item/item-detail.component.ts:63:24)

Any advise on its fix would be highly appreciated.

Here is my use case:

  1. User clicks login button from app
  2. It opens login flow inside web view
  3. User enter credentials inside web view and presses login.
  4. If credentials are correct, webview opens 2FA text box where user needs to input his 2FA code
  5. User opens google authenticator for 2FA code
  6. Opens app again to enter 2FA code
  7. Here, if app is launched from launcher app icon web view tab is already dismissed so user have to start login flow again from beginning.

@jdnichollsc
Copy link
Member

That Unhandled Promise rejection is not related to this library

@jdnichollsc jdnichollsc added the help wanted Extra attention is needed label Feb 8, 2021
@harishchopra86
Copy link
Author

@jdnichollsc Thanks for checking, is there a way to prevent browser closing when application is launched from background by pressing app launcher icon? Please advise.
Thanks.

@jdnichollsc
Copy link
Member

Sorry, honestly I have no idea, but any pull request is welcome! 👍

@harishchopra86
Copy link
Author

I had given it a try already but not able to solve myself so looking for community's help. Struggling with it from last two weeks but can't get any idea to resolve this.

@harishchopra86
Copy link
Author

Adding to above, I looked at ChromeTabsManagerActivity callbacks and found that it's onDestroy callback is called when we open the backgrounded application again by pressing launcher icon and when we open application from recently opened apps nothing is called.

@jdnichollsc
Copy link
Member

Good catch, it looks like a normal behavior with Android, the Activities are destroyed when the launch icon is pressed again

@jdnichollsc
Copy link
Member

Try this approach and let me know 👍 proyecto26/react-native-inappbrowser#213 (comment)

@jdnichollsc jdnichollsc added the discussion 🔥 Discussions about this plugin label Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion 🔥 Discussions about this plugin help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants