Add `Peripheral.PeripheralDisconnected` notificationcenter event on peripheral disconnection
You can now listen to Peripheral disconnection using the Peripheral.PeripheralDisconnected
notification center event.
You can listen to this notification roughly like this:
NotificationCenter.default.addObserver(forName: Peripheral.PeripheralDisconnected, object: peripheral, queue: nil) { (notif) in
if let peripheral = notif.object as? Peripheral {
print("Peripheral disconnected")
}
if let error = notif.userInfo?["error"] as? Error {
print("Peripheral disconnected with error")
}
}
Whereas peripheral
is an instance of Peripheral
.