> For the complete documentation index, see [llms.txt](https://docs.tryterra.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tryterra.co/help-center/help-topics/data-api-sdk/realtime-streaming-and-ble/realtime-keep-alive-backgrounded-ios.md).

# How do I keep BLE streaming alive when iOS 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:

{% stepper %}
{% step %}
Add **Background Modes**.
{% endstep %}

{% step %}
Tick **'Uses Bluetooth LE Accessories'**.
{% endstep %}
{% endstepper %}

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](https://docs.tryterra.co/streaming-api/terra-greater-than-your-backend) for the webhook-based streaming pattern.
