'iOS BLE writeValue while app is in background

I have an app that needs to write a value to a peripheral every 60 seconds, which is triggered by a Timer. This works as long as the app is in the foreground, but as soon as it is sent to the background or the phone gets locked it doesn't work.

"NSBluetoothAlwaysUsageDescription" permission is set as well as "Uses Bluetooth LE accessories" background mode, but at this point, I am not sure if my main issue is Bluetooth related, or due to the fact that my Timer gets killed when the app moves into the background.

I have read Apple's Core Bluetooth Background Processing for iOS, but don't see how it applies to the scenario with a timer:

triggerTimer = Timer.scheduledTimer(withTimeInterval: Double(selectedMinutes * 60 + selectedSeconds), repeats: true) { tempTimer in
   bleManager.trigger()
}

Any ideas how one would go about sending regular BLE write requests while the app is in the background?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source