BLE Central is not scanning near by peripheral when device is locked and screen is off

I’m developing internal application using BLE. Here my app acts as both Central and Peripheral.

When device is locked and screen is off, BLE central is unable to discover advertisement of the device which is locked and screen is off. The same advertisement will be discovered when device is locked and screen light in on.

How to overcome this issue. Is it possible to discover those advertisement?

Apple introduced Exposure Notification API recently and It is only available for Government Health Authorities. As Exposure Notification API is also using BLE, How the above case is handled in it?

Thanks in advance for your help
EsakkiRaja

Replies

It is not going to be possible to make this work reliably when both devices are locked with screens off. There is a set of changes in the system behavior that will make two iOS devices to be able to detect each other not practically feasible.

In general, advertising is done on a best effort basis. As Bluetooth is a shared resource, when other apps and system resources need to use Bluetooth, advertising for apps in the background will slow down, and may even stop for short periods of time. Also, all advertisements for any apps that might be advertising simultaneously will be coalesced into a single advertisement in the most power efficient way. These changes directly effect the probability and time required to be discovered by a scanning device.

On the scanning side, the scan rate also drops once the app is in the background. Scanning rate is also directly related to a timely discovery. The scan rate will further slow down when the phone screen goes off, and even further down after a while when the phone goes to sleep mode after a few minutes of inactivity.

Unfortunately, all these restrictions and slowdowns end up making the discovery process very slow, to the point of becoming unusable. It could potentially take minutes, if not longer.
So, if your use case is that the two devices detect each other promptly when they get close to each other, and both devices are locked with screens off, it will probably not going to work as you wish it did.

As these limitations in behavior is systemwide, and by design for power management purposes, there are no workarounds for this outside of trying to keep at least one side in the foreground.