I have an iOS app that connects to a bluetooth peripheral (think of it as a connected button). The peripheral is in a fixed location so isn't always within range of the iOS device. My app is meant to run as a background task and the peripheral periodically notifies my app of button presses.
I find that iOS sometimes kills my app due to (I believe) memory pressure. I thought that BLE state preservation and restoration would help me:
...by relaunching a killed app whenever the bluetooth connection to the peripheral was restored and a button on the peripheral was pressed. However, this post:
...(the comment by Anton) seems to suggest that state restoration is a bit flaky and can't restore state after BT is turned off/on or after airplane mode etc.
Is this still the case with BLE state restoration. Am I wasting my time trying to get it to work? If it does work, are there any good example implementations anywhere?
If I can't use state restoration, are there any other options?
- keep my app footprint small so it's less likely to be killed by iOS?
- add some kind of keep-alive comms to a remote server that keeps the app alive?
- add functionality such as messaging or VOIP to my app (I know it would need to be legitimate to get through an app store approval). Would that allow the app to be relaunched and a connection reestablished to by BLE peripheral, or does the wakeup only allow VOIP specific API calls?
- Anything else?
Clearly the list above as less preferred to getting BLE state restoration to do the work for me. Any advise greatly appreciated.