scientifichackers / flutter-rx-ble

A Flutter BLE plugin, based on RxAndroidBle and RxBluetoothKit.
GNU Lesser General Public License v3.0
35 stars 18 forks source link

[iOS] State Preservation and Restoration #6

Open fvisticot opened 5 years ago

fvisticot commented 5 years ago

My application is managing a BLE object and I need to manage all cases regarding connection. A great article is describing the pb here: https://uynguyen.github.io/2018/07/23/Best-practice-How-to-deal-with-Bluetooth-Low-Energy-in-background/

and Apple article: https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW10

I do not see how the current library is managing State Preservation and Restoration.

Can you please help ?

What would be fine:

myCentralManager =
[[CBCentralManager alloc] initWithDelegate:self queue:nil
options:@{ CBCentralManagerOptionRestoreIdentifierKey:
@"myCentralManagerIdentifier" }]
- (void)centralManager:(CBCentralManager *)central
--
willRestoreState:(NSDictionary *)state {
 
NSArray *peripherals =
state[CBCentralManagerRestoredStatePeripheralsKey];
valtbarbos commented 4 years ago

Hi guys, any updates on this? This would be a useful feature

@fvisticot tks fo the articles

toniree commented 4 years ago

Hi @valtbarbos I'm currently tackling a similar issue in my own project. Curious what your solution ended up being?

valtbarbos commented 4 years ago

Hi @valtbarbos I'm currently tackling a similar issue in my own project. Curious what your solution ended up being?

Im using another library.

https://github.com/valtbarbos/flutter_blue/tree/master

here an example of background and auto reconnection, tested with iOS 13.1 https://github.com/valtbarbos/flutter_blue/commit/651b121855d64630013a1250c7a790c7a88afd52

I hope it is useful.