-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Enables background usage of flutter-blue #191
base: master
Are you sure you want to change the base?
Conversation
Additional Notes: iOS: Even when a unique ID is set, the app could still theoretically be killed for other reasons by iOS (although I have not experienced this). If the app is killed by iOS at any point and bluetooth-tasks are ongoing, iOS will restart the app and willRestoreState method will be called on the CBCentralManagerDelegate. It allows about 10 seconds to handle the event, before the app is killed again. It may be nice to allow registering a handler in flutter that can be called to handle such events. This would be iOS only. States that can be saved and restored: Additionally it would be good to be able to pass through the application restart reason. Currently flutter has no way of knowing why it was started and main() will run if it was started to handle something through willRestoreState. If it was started to handle this callback, the ideal would be run this in a standalone isolate, passing the various restored states to the handler, but allow the main to exit without attempting to run any code by checking the start reason. |
81078b1
to
40d246d
Compare
Android: Swaps activity() calls for context() where only a context is required. The only place an activity is required is when requesting permissions. This patch will return an error when the plugin is used where permissions have not been granted, and there is no activity available to request permissions iOS: To use bluetooth-central background role and continue to processes in the background it is required that a unique ID (CBCentralManagerOptionRestoreIdentifierKey) be set when the CBCentralManager is initialized. (https://developer.apple.com/documentation/corebluetooth/cbcentralmanageroptionrestoreidentifierkey?language=objc). Delays instanciation of the cbcentralmanager to when it is first used, so allow setting of a unique id from dart. When CBCentralManagerOptionRestoreIdentifierKey is set, the CBCentralManagerDelegate must implement centralManager:willRestoreState. The current implmentation is empty as it appears that setting a unique ID is sufficient to stop iOS killing the app once it has been backgrounded, if a bluetooth connection is active, or a scan is in progress. This has a side effect of printing an API-MISUSE warning when CBCentralManagerOptionRestoreIdentifierKey is not used, because the method centralManager:willRestoreState is always implemented. The warning is harmless when not using CBCentralManagerOptionRestoreIdentifierKey. Dart: To support the setting of a unique Id, introduces setUniqueId(String). This should be called before any methods that will instanciate the native instance of the cbcentralmanager.
changed PR branch and created new PR here |
Any update of this issue ? |
Any Update :) ? |
is there a timeline or even a plan to intgrate this? |
any update ? I've been loooking a way to use the lib in background... |
Can we get this merged? |
Do we have any updates on this ? |
Hi
I have no updates on this
4 Şub 2020 Sal, saat ÖS 4:49 tarihinde Rakshak Raghavan <
notifications@github.com> şunu yazdı:
… Do we have any updates on this ?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#191?email_source=notifications&email_token=ABJMOY6H4E6RSWVJD27LVK3RBFW7XA5CNFSM4GXOB7O2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKXV2BI#issuecomment-581917957>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJMOYYCRTWHY2RRMDM54Z3RBFW7XANCNFSM4GXOB7OQ>
.
|
We really need this. Any ETA? |
hello, i was working in somehit to help this covid pandemic and this its feature its gonna be really helpful, do you have a time where this will be implemented? i actually try to add the code to my code but is still not working. will really appreciate any updated. thanks!! |
Any new on this? Need this feature really bad and would love to get feedback. |
any updates on this? |
Hi Paul, We all need this.Could you please let us know road map to merge this PR ? |
An ETA would be great also is it possible to allow for multiple unique ids? |
Looks like some merge conflicts, but definitely would be useful to have this ASAP. |
is there any update how can i scan results when app is in background |
Why is this still open as you created #210 instead? |
Could you have this fix in last version of plugin?? |
Can this fix go to the latest version? 👍 I consider this a highly requested feature by users |
Any update please? |
What is the current status of flutter blue background processes? |
I think the future is to switch to FlutterBluePlus which is a fork of this inactive repository. It's almost a drop-in replacement and it works well in background... |
Android:
Swaps activity() calls for context() where only a context is required. The only place an activity is required is when requesting permissions. This patch will return an error when the plugin is used where permissions have not been granted, and there is no activity available to request permissions
iOS:
To use bluetooth-central background role and continue to processes in the background it is required that a unique ID (CBCentralManagerOptionRestoreIdentifierKey) be set when the CBCentralManager is initialized. (https://developer.apple.com/documentation/corebluetooth/cbcentralmanageroptionrestoreidentifierkey?language=objc).
Delays instanciation of the cbcentralmanager to when it is first used, so allow setting of a unique id from dart.
When CBCentralManagerOptionRestoreIdentifierKey is set, the CBCentralManagerDelegate must implement centralManager:willRestoreState. The current implementation is empty as it appears that setting a unique ID is sufficient (and the bluetooth-central role) is sufficient to stop iOS killing the app after a few minutes once it has been backgrounded iff a there is ongoing bluetooth activity (connection is active or pending, or a scan is in progress).
This has a side effect of printing an API-MISUSE warning when CBCentralManagerOptionRestoreIdentifierKey is not used, because the method centralManager:willRestoreState is always implemented. The warning is harmless when not using CBCentralManagerOptionRestoreIdentifierKey.
Dart:
To support the setting of a unique Id, introduces setUniqueId(String). This should be called before any methods that will instanciate the native instance of the cbcentralmanager.