PlaygroundBluetoothConnectionViewDataSource
The protocol you adopt to display an available peripheral in a playground page’s connection view.
Declaration
protocol PlaygroundBluetoothConnectionViewDataSource : AnyObjectOverview
The example below shows a conformance to this protocol that uses images from a playground book’s Public and Private Resources Folders.
extension PageViewDelegate: PlaygroundBluetoothConnectionViewDataSource {
func connectionView(_ connectionView: PlaygroundBluetoothConnectionView, itemForPeripheral peripheral: CBPeripheral, withAdvertisementData advertisementData: [String: Any]?) -> PlaygroundBluetoothConnectionView.Item {
let icon = UIImage(named: "Peripheral_Icon_Normal")!
let issueIcon = UIImage(named: "Peripheral_Icon_Issue")!
let name = peripheral.name ?? peripheral.identifier.uuidString
return .init(name: name, icon: icon, issueIcon: issueIcon)
}
}Some peripherals have Bluetooth characteristics that provide information about the peripheral’s battery charge level or firmware status. Include this information in the PlaygroundBluetoothConnectionView.Item you create when it will help people pick a peripheral.