SwiftyBluetooth v2.2.0 Release Notes
Release Date: 2020-11-19 // over 3 years ago-
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) inif 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 ofPeripheral
.