For the complete documentation index, see llms.txt. This page is also available as Markdown.

How do I keep BLE streaming alive when iOS is backgrounded?

Continuous websocket realtime streaming cannot run while the iOS app is backgrounded.

Continuous websocket realtime streaming cannot run while the iOS app is backgrounded. iOS suspends backgrounded apps unless they use a permitted background mode, and a websocket stream isn't among them (beginBackgroundTask only buys limited time).

The BLE connection to the device can persist, though. In Xcode:

1

Add Background Modes.

2

Tick 'Uses Bluetooth LE Accessories'.

Without this, iOS suspends BLE updates shortly after the app leaves the foreground.

The app can then keep receiving sensor data over BLE in the background and periodically dispatch webhook events to your backend, instead of maintaining the websocket stream.

See Terra to your backend for the webhook-based streaming pattern.

Last updated

Was this helpful?