I need to keep my application in the same state it was when it goes back to foreground. Is my only choice to work hard and preserve the full state of the application in some settings file before application goes to background , or can I keep my application alive somehow just like in Android?
2 Answers
There is a good answer on stackoverflow about that.
In summary you can only keep your application running if the application:
- plays audible content to the user while in the background, such as a music player app
- keeps the users informed of their location at all times, such as a navigation app
- supports Voice over Internet Protocol (VoIP)
- is a Newsstand app that need to download and process new content
- receives regular updates from external accessories
In the case of the bluetooth device you have the following modes that you can add in your info.plist:
- external-accessory—The app works with a hardware accessory that needs to deliver updates on a regular schedule through the External Accessory framework.
- bluetooth-central—The app works with a Bluetooth accessory that needs to deliver updates on a regular schedule through the CoreBluetooth framework
For more info check that answer or this tutorial.
In iOS7 you have background fetch but isn't useful in your case.
IMPORTANT Note: If you try to use any of those modes and you don't use what the modes are expecting you to do you might have your app rejected on the appstore.

- 1
- 1

- 14,081
- 3
- 67
- 82
Yes this is possible, in the following cases:
the app plays audio
the app uses location updates (gps)
the app uses voip
the app downloads newsstand items
the app communicates with external accessories
the app uses bluetooth LE accessories
the app acts as a bluetooth LE accessory
the app downloads large files in the background
the app uses remote notifications
To use any of these features, your app needs the "application does not run in background" set to NO and the appropriate flag for the used background mode(s). Note that using these flags while not actually using that specific feature will get you rejected from the iStore.
For more information see the docs.

- 2,739
- 33
- 57
-
Yes, my application uses bluetooth LE accessory! so how can I keep it alive? – user1582281 Dec 03 '13 at 13:20
-
1@user1582281 You can set the flags I mentioned in the xcode project page. For more information on how to actually implement the feature, please see the docs or ask another question ;) – Kevin Dec 03 '13 at 13:21
-
Kevin, I'm using Bluetooth accessory device, but i was told that LE is a new standard and I think that my accessory doesn't support it, can I still set the flag? – user1582281 Dec 03 '13 at 13:52
-
@user1582281 Sorry I'm really not sure. I never used any kind of bluetooth device in my apps, I just typed over the flags. – Kevin Dec 03 '13 at 14:00