我試圖從我的iOS應用程序通知我的Mac應用程序使用CoreBluetooth,但我在中央側的peripheral:didUpdateNotificationStateForCharacteristic:
方法中得到此錯誤:Error Domain=CBErrorDomain Code=1 "One or more parameters were invalid." UserInfo={NSLocalizedDescription=One or more parameters were invalid.}
。CoreBluetooth setNotifyValue無效參數
外設應用程序使用屬性通知和讀取權限初始化onlineUUID特徵。
func peripheral(peripheral: CBPeripheral, didDiscoverCharacteristicsForService service: CBService, error: NSError?) {
for characteristic in service.characteristics! {
if characteristic.UUID.isEqual(self.onlineUUID) {
print("Found online characteristic") // this prints
print("Properties are \(characteristic.properties.rawValue)") // 16==Notify
peripheral.setNotifyValue(true, forCharacteristic: characteristic)
}
}
}
這看起來像在線教程,但它不工作。我重新啓動了這兩個應用程序,清理了項目並重新啓動了Xcode。在iOS 9.2和OS X 10.11.2上使用Xcode 7.2和Swift 2.1.1。非常困惑;請幫忙。
看看這個教程可能可以幫助你,我已經完全爲我的健康設備做了工作。這可能會有助於你的例子 - http://www.raywenderlich.com/52080/introduction-core-bluetooth-building-heart-rate-monitor – KiranJasvanee
你是否通過self.onlineUUID清除if條件? – KiranJasvanee