Skip to content

Add `Peripheral.PeripheralDisconnected` notificationcenter event on peripheral disconnection

Compare
Choose a tag to compare
@jordanebelanger jordanebelanger released this 19 Nov 16:10
· 13 commits to master since this release
c4d31a0

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.