Exit App - iOS

I am trying to get exit the app if the version is out of date (and eventually load the URL to download a new version) on iOS. On a button press or after the validation that the app version is out of date, I have tried the following to close the app. This does work on Android

I keep getting the message ’ ERROR MESSAGE: {“errorMessage”:"",“message”:“not implemented”}


import { Plugins } from '@capacitor/core';

const { App } = Plugins;
export class AuthPage implements OnInit {
  router: Router;
  platform: Platform;

constructor(
    router: Router,
    platform: Platform
  ) {
    this.router = router;
    this.platform = platform;

  }

onClick() {
     navigator['app'].exitApp();
    let val = await App.exitApp();
}
}

Any thoughts would be helpful

Thanks

As I read more in forums, this does not seem like standard practice in iOS. If that is the case, anyone have ideas on how to ensure the user has the most recent version of the app? NOTE: This is distributed as an enterprise app, so it does not go on the app store.

Thanks

I have found this: https://github.com/joycorp/cordova-plugin-exitapp, but I am not sure how to import and reference this plugin… :frowning:

I was facing the same issue today. Seems that Apple do not approve closing apps programmatically and If your app uses such functionality, the binary won’t be approved. I guess that is why the method is not implemented at the first place.

That’s correct, Apple probably won’t like it if you programmatically close. That’s probably why we say in the docs, “This should only be used in conjunction with the backButton handler for Android to exit the app when navigation is complete.”

Instead, here’s what I’ve seen other apps, like Starbucks, do:

  • On app load, compare the current version of the app to the minimum version that the user needs. I’m not exactly sure how others do this, but my guess is through an API call to a backend, that returns the minimum version number.
  • If the minimum version isn’t high enough, then you can block the user from using the app by showing a dialog modal, with something like: “Please update App Name in order to access the latest features.” If they tap an OK button, then open a link to the app in the App Store so they can update.

This wouldn’t be trivial to implement, but it’s one possible way forward.

1 Like

Im solve this with cordova-plugin-exitapp-ios
works with ios and android
I’m using last ionic and vuejs3

npm i cordova-plugin-exitapp-ios

npx cap sync

and you can use this for exit app on ios/android

navigator.app.exitApp();

i hope it helps

Apple don’t allow to close apps programmatically, so, even if it’s possible with the mentioned plugin, don’t use it if you plan to submit it to the App Store.

The plugin readme mentions it

Please be aware that your application may be rejected by Apple when using this plugin.

1 Like

then open a link to the app in the App Store so they can update.

then modal closes and if user doesnt actually update the new version, he can go back to app and use normally. i should add and interval asking the version in that case, im facing this problem with capacitor