在 tvOS 上定义自定义服务和特征

Jee*_*hut 5 bluetooth core-bluetooth swift tvos ios9.1

我想将与 tvOS 一起运行的新 Apple TV 设置为具有自定义服务的蓝牙外围设备,以便它可以与对应的 iPad 应用程序进行通信(iPad 是中央蓝牙设备,可以被视为 Apple TV 应用程序的遥控器)。

Apple 提供了一个编程指南,可以在这里执行此操作但它似乎已经过时了(甚至是它的预发布版本):

据的iOS的版本注释9.1 / tvOS的初始化方法两者的CBMutableCharacteristic类和CBMutableService中除去,并且不再提供tvOS(使用的XCode 7.1)。您可以在此处找到 CoreBluetooth 框架中的相关更改。

我试图直接使用类的startAdvertising方法,CBPeripheralManager它调用peripheralManagerDidStartAdvertising委托方法没有这样的错误:

let peripheralManager = CBPeripheralManager()
let myCustomServiceUUID = CBUUID(string: "12345678-ABCD-1234-ABCD-123456789ABC")

func peripheralManagerDidUpdateState(peripheral: CBPeripheralManager) {
    if peripheral.state == .PoweredOn {
        print("Bluetooth state is OK.")
        self.startProvidingSecondScreenForTestsService()
        self.peripheralManager.startAdvertising([CBAdvertisementDataServiceUUIDsKey: [self.myCustomServiceUUID]])
    }
}
Run Code Online (Sandbox Code Playgroud)

但是我不知道如何在没有沿途定义的任何特征的情况下以这种方式交换数据

我是否在这里遗漏了什么(也许有另一种/更好的方式来定义这些对象),或者Apple 是否出于某种原因故意删除了新 Apple TV 上的自定义服务和特性的功能