Closed theedov closed 1 year ago
Hmm, I think I have to use combine here and cancel the characteristicValueUpdatedPublisher
manually.
notification = peripheral.characteristicValueUpdatedPublisher.sink(receiveValue: { characteristic in
guard characteristic.uuid == Constants.Device.sensorUUID.cbuuid else { return }
let parsedValue: Int? = try? characteristic.parsedValue()
})
...
notification?.cancel()
Hello,
How do I stop the notifications correctly? My current situation is that when I try to enable - disable - enable notifications, I then get duplicated values. More times I disable/enable, more duplicates I get. So basically if I disable/enable 5 times, I then get the same 5 values returned from the
characteristicValueUpdatedPublisher
at the same time.Here is my code:
Start notifications:
Stop notifications:
Note: I also tried
try await peripheral.setNotifyValue(<#T##enabled: Bool##Bool#>, forCharacteristicWithUUID: <#T##UUID#>, ofServiceWithUUID: <#T##UUID#>)
.