-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Help]: flutter_blue_plus with flutter_foreground_task combination failes, when app get backgrounded
#924
Comments
never tried this before |
did you think i could use something like this? https://github.com/flutter/samples/blob/main/background_isolate_channels/lib/simple_database.dart to get the plugin/startScan useable from a background isolate? |
Im unfamiliar. good luck & report back. |
i tried this also
also with different ble libs, it doesn't scan. The problem is that I see the log print from FlutterForegroundTask.onRepeatEvent at intervals of 6s. So it would work if you could scan every 6s, but that's exactly where my problem lies. As soon as you start the scan, nothing happens, scanResult is empty. But I don't see why the scan is prevented. As I said, I've already set up and tried lowPower and similar variants. |
I'd try making it work with a native app next so you can understand how it is supposed to work |
some docs Scanning BLE in the background on mobile platforms can be challenging due to the operating system's restrictions on background activities to conserve battery life. However, both Android and iOS provide ways to perform BLE scans in the background with some limitations. AndroidOn Android, you can use the
iOSOn iOS, you can perform limited BLE scanning in the background by enabling the appropriate background modes in your app. However, the scanning interval and duration are restricted by the OS.
These are simplified examples to get you started. You may need to handle more scenarios and edge cases depending on your app's requirements. Additionally, always test thoroughly on actual devices to ensure compliance with the latest platform guidelines and restrictions. |
thanks for your help. i tried it already to understand with a fork of this a repository and added much more debug logging output. as i can say at the moment, somethings stops calling the |
I'm using a Service, and the app is working perfectly with Bluetooth. I can synchronize data periodically. Currently, I'm facing a similar issue. When the Bluetooth device goes out of range and comes back into range after a few minutes, using flutter_blue, I can start a scan by passing the device ID, but it always returns an empty list. Note: the app is minimized, and the screen is locked. When I unlock the screen, this periodic service, when executed, can then find the device. But with the screen locked, it always returns an empty list of devices. |
closing in favor of new issue |
Requirements
Have you checked this problem on the example app?
No
FlutterBluePlus Version
1.32.8
Flutter Version
3.22.0
What OS?
Android
OS Version
Android 14
Bluetooth Module
unspecific
What is your problem?
I am trying to combine flutter_foreground_tasks with BLE scanning, whether the app is running visibly or in the background, everything works perfectly. But as soon as I turn off the screen and the log message goes through.
I/FA (24762): Application backgrounded at: timestamp_millis: ...
nothing works anymore. No matter how I try it. With continuous scanning, or every 6 seconds in onRepeatEvent (so that startScan is not called more than 5 times in 30s), it no longer delivers any results.I have turned on all possible permissions
and also tried several combinations in ForegroundService.
Does anyone else have an idea what else I could try to wake the phone up again when I find a very specific BLE device?
Logs
The text was updated successfully, but these errors were encountered: