0

尽管我指定了两个服务 UUID 和服务,IOS 只宣传一项服务,但我没有收到任何错误,并且添加服务错误函数被调用了两次,两次都没有错误,这是我的代码

for UUIDs in advertisingUUIDs
{
    self.mainServicesArray.append(CBMutableService(type: UUIDs, primary: true))
}

for services in mainServicesArray
{
    self.peripheralManager.addService(services)
}

self.peripheralManager.startAdvertising([CBAdvertisementDataServiceUUIDsKey: [mainServicesArray[0].UUID,mainServicesArray[1].UUID]])

其余代码运行良好,在我放在那里的示例中,它将宣传两个服务中的第一个,顺序无关紧要,第一个总是宣传第二个不,所以 UUID 是有效的服务它不会同时宣传它们,我确信它很简单,但我被卡住了。

谢谢

4

1 回答 1

0

原因是第二个 UUID 不适合广告数据包。

当我扫描连接的设备时,第二个服务仍然没有显示,但这是另一个问题。

于 2016-01-08T11:34:51.903 回答