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.