iOS4 - Make App not run in background
Does anyone know of anyway to make the app not run in the background on iOS4 when built using SDK 4.0?
My App is not really designed to run in the background, and if someone doesn't finish the task when they close the app it causes problems.
So I would like the app to "close" when the home button is pressed, so when the user opens the app again it starts up fresh.
Does anyone know how to do this?
Thanks
14 Answers
-
Andy,
Go to your info.plist in the build folder and edit it with a text editor and add this.
<key>UIApplicationExitsOnSuspend</key> <true/>
-
Adding UIApplicationExitsOnSuspend AND copying the info.plist file to the project root is the solution.
-
The project's root is the folder above the Resources one, the folder that has tiapp.xml file.
There you should put your Info.plist file.Simply copy the file found in
build/iphone
and add the key specified by Donovan
<key>UIApplicationExitsOnSuspend</key> <true/>
delete the folder
build/iphone/build
to force a full rebuild and you should be set.
PS. All the above folder path are relative to the root of the application.
-
Martijn,
Thanks for that. I actually did get it to work. I had to add it into the info.plist as a boolean type.
<key>UIApplicationExitsOnSuspend</key> <true/>
Thanks again
-
This by text edit is working:
<key>UIApplicationExitsOnSuspend</key>
<true/>This by Xcode is not working:
<key>UIApplicationExitsOnSuspend</key>
<string>true</string> -
you supposedly can set UIApplicationExitsOnSuspend to true in the info.plist, and the app should exit.
-
Are there any other things to consider for this? I tried adding UIApplicationExitsOnSuspend to Info.plist and Info.plist.template (both in Xcode proj root - same level as .xcodeproj file in build/iphone/build) and it does not work. I feel like an idiot for not being able to get this to work. Thanks!
-
I can confirm the code mentioned above works.
When I tried it at first it didnt work. It could be because used a text editor to edit the info.plist. So maybe my text editor is not plist-friendly. Danno suggested to edit the file in XCode and add the key (boolean), and that works. I copied the info.plist now into my root directory in case I want to delete the build folder so I wont have to edit the file again.
-
This by text edit is working:
<key>UIApplicationExitsOnSuspend</key>
<true/>This by Xcode is not working:
<key>UIApplicationExitsOnSuspend</key>
<string>true</string> -
This by text edit is working:
<key>UIApplicationExitsOnSuspend</key> <true/>
This by Xcode is not working:
<key>UIApplicationExitsOnSuspend</key> <string>true</string>
-
To get the mobile application in iphone to close when the home button is clicked instead of continuing to run in the background first build your project for iphone.
Next go into the iphone's build folder and copy the info.plist file
build/iphone/Info.plist
Paste this file in the root directory for the whole project (the folder above the Resources folder)
Edit the file with a text editor (not xcode) and add this xml code before the </dict> element
<key>UIApplicationExitsOnSuspend</key> <true/>
Save and rebuild and now it will close the application instead of suspending it to the background.
-
is there anyway I can set this programatically? My App needs to run in the background optionally, for example, when it downloads file, I want it to be able to run in the background, and otherwise, I want it to exit.
thanks ahead
-
You can do it right in Xcode…for those in the future that needs help heres how:
Click on "Info.plist" under Resources folder in the Xcode. Should show all the Keys it contains. Right click anywhere on that and "Add Row" (usually I select the last row to insert a new row to the bottom) Type in UIApplicationExitsOnSuspend for the key then press ENTER. Then right click on the key you made and select "Boolean" from the "Value Type". It will give you a check box next to it and simply just mark it. For future reference, to delete a row just click on a row then hit DELETE or select a row and Edit –>Delete
-
Is this really working? I have tried this on three different Apps including a default bare bones build and changing the plist file to include this has had no affect whatsoever. The Apps effectively suspend on pressing of the home button and resume on restart of the App. Im using Titanium 3.2 with 4.0SDK. I have tried using both True and YES for the boolean and still no joy. I urgently need to have my App fully close and not go into this suspend mode. Help!