0

Is there a way to programmatically exit & kill an iOS app which is running in "single app mode" everyday at a specific time?

Also is there a way to start / launch the same app automatically at another specific time?

Basically, I want the exit/kill the app at the close of business hours everyday and automatically start/launch the app every morning.

Is this possible with iOS programming or even with the help of any MDM tools? if yes, what are the steps / details to achieve the same?

Jinnah
  • 148
  • 10
  • 1
    I thought it would be worth mentioning that you do not want to do this if your app is in the foreground. Programmatically exiting your app while it is active in the foreground is forbidden by Apple and your app will be rejected from the Appstore. – Garret Kaye Jan 05 '17 at 17:01
  • if you are developing an MDM server, then it is possible. The trick is to have at least two apps on the device, remove SAM profile for APP 1 and apply SAM profile for APP 2. Then remove SAM profile for APP 2. This will result in APP 1 being closed, APP 2 being open and device NOT in Single App Mode. Then, whenever needed, you can again apply SAM profile for APP 1. – zaitsman Jan 24 '17 at 12:28

1 Answers1

1
exit(0)

is the code to kill your app programatically. How you do it is at a particular time or event is left upto you. You can send a push notification and kill the app on the push notification or a local notification which is fired at a particular time.

While as for starting up an app it is not possible unless it be for VOiP apps which are brought into foreground directly in case of an incoming call.

Hope this helps and clear out your doubts.

Happy Coding!

Please refer these SO Post 1, SO Post 2, Restarting App.

But using exit(0) would lead to app rejection on AppStore.

Community
  • 1
  • 1
Md. Ibrahim Hassan
  • 5,359
  • 1
  • 25
  • 45
  • 4
    Note that you can't submit an app to the app store containing exit() as it will be rejected by Apple. However as MDM is mentioned in the question maybe the app is not intended for app store submission. – Gruntcakes Jan 05 '17 at 17:02
  • Yes I forgot to mention thats is completely true and valid. – Md. Ibrahim Hassan Jan 05 '17 at 17:04
  • 1
    Yes. Not intended for app store submission. It's internal app. – Jinnah Jan 05 '17 at 17:05
  • then you are good to go but no delegate functions would be called incase tyou use exit (0). The link suggests. And as for reopening the app the VOiP push notification would work perfectly. – Md. Ibrahim Hassan Jan 05 '17 at 17:07