IOS: Bluetooth LE background app

bluetoothiosmultitasking

I severly suffer from iOS (supposedly) killing my apps all the time although I purpusefully do not kill them. They are also listed in the task manager (double tap on home).

This is especially bad for at least two of my apps:

  1. HID Mobile Access (keyless entry system)
  2. Noke (Bluetooth pad lock)

For the former, all that should need to be done is to shake the phone. Then card reader should activate and open the door. For the latter, only the shackle of the pad lock should have to be pushed and it should automatically unlock if the phone is nearby (i.e., in my pocket).

BOTH nearly never work, rendering them nearly useless (if I need to dig into my bag to find the phone I can also dig for the key or the RFID card).

Both work when I manually start the app (and shortly after) but then randomy fail again after some time.

Both apps have a background app refresh option which I have activated.

The developers of the apps claim that this would be a limitation of iOS and the functionality would not work. I would fine it bold to advertise a functionality that can't even work …

Shouldn't background app refresh allowing exactly this … keeping those kinds of things working?

I also have an Apple Watch and there I never experienced communication loss or problems.

How does the background app refresh work exactly for Bluetooth LE? Is there a function to probe for a Bluetooth LE device in the background?

Are the developers of these apps just making up excuses?

(Tile is another Bluetooth LE app with the same problems. However, here I don't mind too much)

Best Answer

It is indeed challenging to get that functionality to work reliable, since iOS has a very conservative power saving mechanism and developers are not making things up.

The problem is: While there actually is a way for Apps to use Bluetooth LE while in the Background, it's very limitated. Typically, to connect to a BLE device like Noke, the App needs to scan on for the device which advertises is presence. Only after a scan is received, the app can actually connect to the device. A device issues a scan using iOS system services and registers a callback, which means the OS "calls"/"activates" the app if a device that was scanned for is found.

When scanning for a device, there are several parameters that can be tuned that affect power intensity but also latency when interacting with BLE. In gerneal, you need to balance these parameters for the best experience. In foreground, scanning for and connecting to devices is very quick on iOS, but in background, iOS ignores some options developers can configure but foremost, it reduces the frequency of the scan which greatly reduces the power usage, but also introduces a lot of latency. iOS also decides when to issue the callback to the app described above.

I made the discovery that power saving on iOS 11.1 is way more aggressive then on iOS 10. Are or where you using iOS 11 when those problems occured?

Source: https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW1