jordanebelanger / SwiftyBluetooth

Closures based APIs for CoreBluetooth
MIT License
209 stars 66 forks source link

How to get the state when the peripheral is disconnected? #47

Closed mmswide closed 3 years ago

mmswide commented 3 years ago

func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) I need to get this callback when the peripheral is disconnected. How can I get this to work? Many thanks.

mmswide commented 3 years ago

I will use original CBCentralDelegate and CBPeripheralDelegate.

jordanebelanger commented 3 years ago

@mobileguru121 If you want, I believe there is an NSNotification you can listen for. Check the interface of the Peripheral class it should be there.

mmswide commented 3 years ago

Thank you, but I could not find it. I appreciate if you can teach me.

jordanebelanger commented 3 years ago

Sure, perhaps you are on an older version, this was recently added.

Make sure to update to the latest version and check out https://github.com/jordanebelanger/SwiftyBluetooth/blob/65e47a63740254738d4262e2ee214cdff366c8c2/Sources/Peripheral.swift#L77

mmswide commented 3 years ago

Ok, thank you. I have to update the pod version to latest.