How to reboot or reload iPhone app programmatically in iOS

13,581

Solution 1

Rebooting the app is a bad idea, I'm pretty sure Apple would reject it. However, You could display a popup telling the user to open a close the app to apply your updated information. But the best way would be just to manually call the methods needed to rebuild your app (I.e. the ones that need to use the updated data). If you have to do some extensive rebuilding (i.e. things that the user would immediately notice) it might be a good idea to add in a "loading" progress bar of sorts.

Solution 2

You can't reboot your app, and I don't see why you would a) have to b) EVER WANT TO.

Solution 3

You can quit and restart an iOS app with a bit of user assistance. Set the app's plist key for application exits on suspend. Create a local notification for your app to trigger a few seconds into the future. Then send Safari a URL. The OS will terminate your app when launching Safari to handle the URL. The URL might be to a web landing page telling the user that a relaunch is in progress. Then the local notification will go off and ask the user to relaunch your app.

However an app should be (re)designed so that there is never a reason to do this.

Solution 4

You can do it only if your device is jailbroken

Put a reboot button in your app and call abort();. This will crash the app.

Hook the -(void)exitedAbnormally; from SBApplication and write code to launch your app.

If its not jailbroken, you have no choice

Share:
13,581
Jaume
Author by

Jaume

Updated on June 22, 2022

Comments

  • Jaume
    Jaume almost 2 years

    I have dowloaded an xml file that contains some update parameters and then I need to reload these parameters and init some views. Easiest way is to apply this configuration on next app boot. Is there any way to reboot iOS application programmatically?

    Thank you.

  • Mattias Wadman
    Mattias Wadman about 12 years
    I know the feeling, but what do you do when the client wants to have app specific locale configuration (i don't like that either) without paying for the actual work for doing it properly.
  • sosborn
    sosborn about 12 years
    You point to the clause in your contract that talks about "scope" and extra costs. Anyway, best of luck to you - Amit's answer is perfect.
  • Mattias Wadman
    Mattias Wadman about 12 years
    Thanks. I upvoted amit's answer myself and I will remove my answer as you made me remember how much i hated doing that solution.
  • Nick Turner
    Nick Turner almost 11 years
    exit(0) will quit the app without jailbreaking
  • Nick Turner
    Nick Turner almost 11 years
    A condition that is quite possible, but rare is if the controller maintained by your storyboard get released by arc. I've seen it happen once. At that point it's better to just exit then try to save it.