I am trying to get the notification from a bluetooth device upon the characteristic value change. For this I need to enable notification for Client Characteristic Configuration(CCC) descriptor. I have used setNotifyValue(enabled: Bool, forCharacteristic characteristic: CBCharacteristic)
for the characteristic but not getting the update for value changes.
I tried to enable the indication for CCC using writeValue(data: NSData, forDescriptor descriptor: CBDescriptor)
but my app crashes for this API and shows the error as
Cannot write Client Characteristic Configuration descriptors using this method!
Any help!!
Provide more codes might help to imporove accuracy of an answer; however, let's be assuming you have already been able to discover all characteristic values. Usually you just need to iterate all characteristics and set/write value according to each Client Characteristic Configuration(CCC) descriptor in
CBPeripheralDelegate
implementation.An example is attached below: