Open dennislysenko opened 3 months ago
This is a very interesting question. I still don't have the final verdict and need to carry out more tests, but it seems there are a whole lot of factors involved:
In one of my production apps, I'm using BLE via L2CAP COC. This app has only [x] Uses Bluetooth LE accessories enabled and survives 27 seconds in background, before the app is killed. The L2CAP connection holds for so long, but (naturally) gets closed when the app is killed.
Let me do the silent audio trick next week and check whether I can get the L2CAP connection to hold any longer. I'm also not sure whether L2CAP COC has any other runtime characteristics than the standard BLE connectivity.
Like I said, this is a complex, but very interesting topic and authoritative or definite information are little. Perhaps we can work together here, sharing our experiences.
I have had my app run for much longer than 30s in background, but I dont think it has lasted longer than 30m. I will need mine to run for hours in the background. I am interested in this topic.
Hi @mickeyl, first off, thanks for helping to troubleshoot the other issue I had recently.
I was curious what the expected behavior is of BT when going into the background. I have this app using LTSupportAutomotive, that runs a web server in the background using the silent audio trick exposing OBD readings that are polled every 0.3s (we're just running it via Testflight, it doesn't need to pass app review).
Project: https://github.com/dennislysenko/OBD2Loxone
We have all these background modes selected. However when going to background, the web server keeps running for hours (indicating that the app is still awake, as intended), but the BT connection seems to go down.
Do you know what the expected behavior is of BLE under these conditions, when the app is running in the background (not getting killed)? I did a quick search for any UIApplicationDidEnterBackground etc. in the LTSupportAutomotive repo, and didn't find any reason to think the library would switch off BT connections when backgrounding.