Skip to content
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

centralManager(_:willRestoreState:) #11

Closed
abrown-sram opened this issue Mar 3, 2024 · 1 comment
Closed

centralManager(_:willRestoreState:) #11

abrown-sram opened this issue Mar 3, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@abrown-sram
Copy link

I have been playing with the library this week and so far am pleased with the features. One thing I noticed is that the ReactiveCentralManagerDelegate seems incomplete. Specifically missing the willRestoreState instance method.

https://developer.apple.com/documentation/corebluetooth/cbcentralmanagerdelegate/1518819-centralmanager

Perhaps this is still planned for a future release. If so please let us know when!

Thanks.

@dinesharjani dinesharjani added the enhancement New feature or request label Mar 4, 2024
@NickKibish
Copy link
Collaborator

Hi @abrown-sram ,

Thank you for your feedback and for exploring the library!

Regarding the missing centralManager:willRestoreState: method in the ReactiveCentralManagerDelegate, the reason it has not been implemented directly in the library is to avoid potential issues related to the lack of a restoration identifier.

If we were to implement it without providing a restoration identifier, it would lead warnings in the console.

Warning

API MISUSE: <CBCentralManager: 0x6000024c0280> has no restore identifier but the delegate implements the centralManager:willRestoreState: method. Restoring will not be supported.

To address this, the library has been designed to allow users to easily implement missing features themselves. Here's an example of how you can implement the centralManager:willRestoreState: method in your code:

// 1. - Implement your own delegate, overriding ReactiveCentralManagerDelegate
class MyCentralManagerDelegate: ReactiveCentralManagerDelegate {
    // 2. - Implement the missing method
    func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any]) {
        print(dict)
        // Or perform any other necessary actions
    }
}

// 3. - During initialization of `CentralManager`, pass a custom delegate and options
let cm = CentralManager(centralManagerDelegate: MyCentralManagerDelegate(), options: [CBCentralManagerOptionRestoreIdentifierKey: "YourRestoreIdentifierKey"])

Feel free to reach out if you have any more questions or if there's anything else I can help you with.

@NickKibish NickKibish pinned this issue Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants