flutter-rx-ble icon indicating copy to clipboard operation
flutter-rx-ble copied to clipboard

[iOS] State Preservation and Restoration

Open fvisticot opened this issue 5 years ago • 3 comments

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:

  • Allow to set an identifier when creating the centralManager:
myCentralManager =
[[CBCentralManager alloc] initWithDelegate:self queue:nil
options:@{ CBCentralManagerOptionRestoreIdentifierKey:
@"myCentralManagerIdentifier" }]
  • add a "callback" when the restoration is fired with devices and states :
- (void)centralManager:(CBCentralManager *)central
--
willRestoreState:(NSDictionary *)state {
 
NSArray *peripherals =
state[CBCentralManagerRestoredStatePeripheralsKey];

fvisticot avatar Jun 16 '19 07:06 fvisticot

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

@fvisticot tks fo the articles

valtbarbos avatar Nov 21 '19 14:11 valtbarbos

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

toniree avatar Jun 06 '20 00:06 toniree

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.

valtbarbos avatar Jun 06 '20 00:06 valtbarbos