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

Feature Request: Please add support for App.minimizeApp() #130

Closed
naveedahmed1 opened this issue Sep 7, 2019 · 4 comments · Fixed by #743
Closed

Feature Request: Please add support for App.minimizeApp() #130

naveedahmed1 opened this issue Sep 7, 2019 · 4 comments · Fixed by #743

Comments

@naveedahmed1
Copy link

Description of the problem:

Currently we are able to use hardware back button to exit app by listening to backButton event and then calling App.exitApp();:

App.addListener('backButton', (data: AppUrlOpen) => {
            if (!(this.routerOutlet && this.routerOutlet.canGoBack())) {
                App.exitApp();
            }
        });

It would be great, that if an option to Minimize App could also be added to the capacitor and we could use something like App.minimizeApp();

There's a cordova plugin https://github.com/tomloprod/cordova-plugin-appminimize for this purpose, but I believe since its a common use case, it should be added to the Capacitor.

Affected platform

  • [x ] Android
  • [ x] iOS

OS of the development machine

  • [x ] Windows
@imhoffd imhoffd transferred this issue from ionic-team/capacitor Dec 8, 2020
@Ionitron Ionitron added the triage label Dec 8, 2020
@imhoffd imhoffd reopened this Dec 8, 2020
@phal0r
Copy link

phal0r commented Feb 14, 2021

I wanted to solve this problem for ionic react, but unfortunately there is no canGoBack() function, which could indicate, that we are on the first entry of the history stack. So even if capacitor would have a minimize function, it would not work well for ionic react.

At the same time I had a look at the cordova minimize plugin and the capacitor app plugin and I want to suggest the following:

Capacitor app plugin has built-in support for navigating back with the hardware back button on android. See: https://github.com/ionic-team/capacitor-plugins/blob/main/app/android/src/main/java/com/capacitorjs/plugins/app/AppPlugin.java#L45

The app plugin could be enhanced with setters to enable minimizing or closing the app, if bridge.getWebView().canGoBack() returns false. This would be quite easy to achieve and would be transparent for any js framework and flavor, that is being used for development. Straightforward documentation and less traffic on the bridge as it is handled native completely. Thoughts on that?

@kawazoe
Copy link

kawazoe commented Mar 11, 2021

@phal0r The behavior of the back button does not always depend on the webview's ability to go back, but might depend on the ability of a specific router-outlet to go back. For instance, with multiple tabs, while the web view might be able to go back "across tabs", this is not necessarily desired. This is how I usually implement it in Angular. I am not familiar with routing in ionic react, but you probably have an equivalent feature, or the ability to save this information in your store.

Either way, the App.minimizeApp() API is still a must.

@nothingkid
Copy link
Contributor

Added "minimizeApp" method to "app" plugin
#743

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 30, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants