I am using core-bluetooth framework for my app in Iphone-4s.
This is typically has to be a background app which can run as longer as possible.
Now it is only running for 40 min - 1 hour max.
I am hoping for at least 1 day or so.
For this "bluetooth-central" value is added in "Required background modes" key in .plist file.
It seems like my app is going to "suspend" mode, at the end. since when I open the app again (background to foreground state) it is sending the notification again, it means the bluetooth connection is still connected and BLE-device is still sending notification. If i press home button and app comes to background, it does NOT get notification again.
Can anybody tell me why my app live in background mode only for max 1 hour. It should continue run like normal music app in background for like forever.
Is Apple say anything specific about on which condition an background app (which is one of those continuous running background app falling with in the 5 categories) failing which it will go to suspend mode?
Referring "iPhoneAppProgrammingGuide
", on "Communicating with a Bluetooth Accessory
" section,
I come to know that, for long running background task for Bluetooth LE application 2 implementations are necessory:
1) UIBackgroundModes key should be "bluetooth-central" in Info.plist
file.
2) Any app that supports the background processing of Bluetooth data must be session-based.
So for my app, the FIRST implementation was incorporated, and with that application is able to run in background and do all the tasks for
max 1 hour duration.
Now I need to implement 2nd implementation. i.e. session-based. Which will allow to get the events even if the app is in "suspend" state
according to the documentation. I tried to find to create a suitable session specific to Bluetooth LE (Core Bluetooth framework) like the
"EASession
" present for Classic Bluetooth (External Accessory framework). But I did not find it.
Basically I am not sure which session class i need to use for BLE purpose. For audio/video, networking and internet, external accessory,
there are individual session class available. There is none for Core Bluetooth framework.
Could anybody help me with, which session class is suitable for BLE.
See Question&Answers more detail:
os