How to wake up app in background

Team, is there anyway, if we can wakeup the app while it is in suspended mode.

I am using BLE scanning to share/receive the TCN token and generate notifications, but while app in sleep/suspended mode it stops.

is there anyway to trigger this scanning or wake up the app without any manual intervention. we are trying to achieve this with help of silent notifications.
can you help to figure out how many silent notification we can trigger in an hour ?

Replies

If you are interacting with a BLE device, that will be the best way to wake up your app. Silent notifications will not be consistent enough if you need several wakeups per hour.

If the BLE device is not waking up your app when suspended, then it is mostly likely because it is not advertising fast enough. Or the advertising does not include the UUID your app is scanning for.

The advertising interval of your peripheral effects the time to discovery and connect performance, which in turn would wake up your app.

To have a high probability of being discovered by an iOS device you should first use the recommended advertising interval of 20 ms for at least 30 seconds. If it is not discovered within the initial 30 seconds, you can switch to using one of the following longer intervals to increase chances of discovery: 152.5 ms, 211.25 ms, 318.75 ms, 417.5 ms, 546.25 ms, 760 ms, 852.5 ms, 1022.5 ms, 1285 ms

How long you need to keep advertising after the initial 30 seconds will depend on your required time to discovery. The probability and time curve is asymptotic.

Also, as an app scanning in the background has to scan for specific service UUIDs, to be able to be discoverable under all conditions, the peripheral should advertise at least one of the UUIDs the app scans for in the ADV_IND packet, as opposed to the SCAN_RSP packet.

These and many other important aspects of detection and connection is discussed in the Bluetooth Accessory Design Guidelines for Apple Products which can be found here: https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf

for ble scan to happen in background does the user have to enable location services? do we have to request for location permissions to be able to scan for a specific ibeacon UUID. I also have a use case which is similar to this wherein I need to wake up the app in case it is not running, the only caveat here is I dont want the user to have to enable location services.

A followup on this: if an app has bonded with a bluetooth device earlier, can this bluetooth device connection be used to wake up the app (what we see with spotify et al when the phone connects to my car)