Joachim Jablon
Joachim Jablon

Reputation: 958

iOS : Keeping application alive in background while waiting for a connection

I'm developing an iOS 5 application using BLE that needs to monitor connections to a Bluetooth device for several hours. I've been using the bluetooth-central in my plist for UIBackgroundModes, and it worked great to keep the application running as long as the device is connected. When it disconnects, I try to reconnect it, and as soon as the device starts advertising again, it also works great.

The problem is that if it disconnects and the user starts using other applications, it won't reconnect.

I've been trying to see what the problem is, and as far as I understood, when the memory level is low, my app can't be killed if a device is connected, but it can (and will) be killed if nothing is connected. I can see my app gets jettisoned in the "LowMemory" logs of the iPhone.

How could I ensure that my app doesn't get jettisoned ?

Upvotes: 4

Views: 1666

Answers (2)

Antoine F.
Antoine F.

Reputation: 393

Sadly, like Apple doesn't let you decide what is a necessary services, you could use a simple workaround, activate GPS in background too or a silent sound.

Of course, it will be a battery consuming workaround, and your app validation could be rejected.

Upvotes: 0

J2theC
J2theC

Reputation: 4452

You don't. iOS watchdogs are prepared to free up as many resources as possible to ensure the proper execution of the foreground application. Since your application is no longer in the foreground, iOS will allow the app to run the necessary services, as long as it has enough resources to do so. I've had similar problems with location services running in the background.

Check the memory footprint of your application while running in the background. Release stuff you do not need. This will decrease the frequency in which your app is killed.

Upvotes: 4

Related Questions