How does bluetooth work while the app is backgrounded? #679
Replies: 1 comment 4 replies
-
On iOS, background scanning is a bit finicky. How long are you pushing the app into the background and waiting before you'd expect the scan response to trigger? With the default approach used by this plugin, the app will not be correctly reloaded if iOS pauses the app in the background, as there is no support for iOS state restoration. If you had a simple enough test harness... it would be interesting to know if another plugin (https://github.com/don/cordova-plugin-ble-central?tab=readme-ov-file#background-scanning-and-notifications-on-ios) might behave differently here? Just as an aside, with the Android app you'll need to wait at least 5 minutes to properly test that your application responds. Most hybrid web views pause execution of JS code 5 minutes after being put into the background. Additionally, Android power saving mode tends to kick in about 40mins => 1hr later if the app remains in the background. |
Beta Was this translation helpful? Give feedback.
-
I am attempting to scan for a specific bluetooth device while the app is in the foreground, but also while the app is in the background (and even with the phone locked). On iOS I have added bluetooth-central to UIBackgroundModes, however the code in the callback for requestLEScan never seems to trigger when the app is backgrounded. I'm not sure if the scanning is not working, or it is unable to run the hybrid code while the app is backgrounded.
Android seems to be working as intended when passing the scan mode of SCAN_MODE_LOW_POWER.
Is this not the way background bluetooth scanning works with this plugin?
Any help would be appreciated. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions