IOS: keeping application in the background while waiting for a connection

I am developing an iOS 5 application using BLE that needs to track connections to a Bluetooth device for several hours. I use bluetooth-center in my plist for UIBackgroundModes, and it worked perfectly so that the application works as long as the device is connected. When it turns off, I try to reconnect it, and as soon as the device starts advertising again, it also works fine.

The problem is that if he disconnects and the user starts using other applications, he will not reconnect.

I tried to understand what the problem is, and as I understand it, when the memory level is low, my application cannot be killed if the device is connected, but it can (and will) be killed if nothing is connected. I see that my application is being dumped to iPhone's "LowMemory" logs.

How can I guarantee that my application will not be dropped?

+4
source share
2 answers

No. IOS observers are ready to free up as many resources as possible to ensure that the foreground application runs correctly. Since your application is no longer in the foreground, iOS will allow the application to run the necessary services if it has enough resources for this. I had similar problems with background location services.

Check the memory area of ​​your application while running in the background. Free things you don't need. This will reduce the frequency at which your application is killed.

+4
source

Unfortunately, like Apple, you cannot decide which services you need; you can use a simple workaround, activate GPS in the background, or quiet sound.

Of course, this will be battery life, and the verification of your application may be rejected.

0
source

Source: https://habr.com/ru/post/1433370/


All Articles