0

I've tried the two following approaches to close my ionic app but non has worked.

1.

closeApp(){
    this.platform.backButton.subscribeWithPriority(999999, () => {
       navigator['app'].exitApp();      
    })
}

In this approach, when I click on the back button, the app is disappeared, but it's in the list of the background running apps. This doesn't help me, because I need the app to be completely closed and the user be forced to reopen the app by clicking on its icon.

2.

closeApp(){
   const { App } = Plugins;
   App['exitApp'];
}

in this case, nothing happens, i.e., I stay on the page.

Is there any other approach or plugin which I can use? I am working with capacitor: 3 and testing on android 12.

user9805040
  • 73
  • 1
  • 9
  • use https://www.npmjs.com/package/cordova-plugin-exit –  Feb 19 '23 at 01:39
  • I am not sure how to use this plugin. After installation,I followed this [answer](https://stackoverflow.com/questions/32656764/how-to-use-navigator-app-exitapp-to-exit-application-in-cordova-on-ios-platfor) to use it, but I don't have a `build.xml` file. I've several `config.xml` files, in which one I have to add the plugin (if it's necessary)? – user9805040 Feb 19 '23 at 11:33

1 Answers1

0
import { App } from '@capacitor/app';

  ExitApp() {
  App.exitApp();
  }

try this