Just looked at doc, did not test.
Isn't the instance method of CBPeripheral done for this ?
Sets notifications or indications for the value of a specified characteristic.
func setNotifyValue(_ enabled: Bool, for characteristic: CBCharacteristic)
enabled
A Boolean value indicating whether you wish to receive notifications or indications whenever the characteristic’s value changes.
true
if you want to enable notifications or indications for the characteristic’s value.
false
if you do not want to receive notifications or indications whenever the characteristic’s value changes.
characteristic
The specified characteristic.
When you enable notifications for the characteristic’s value, the peripheral calls the
peripheral(_:didUpdateNotificationStateFor:error:)
method of its delegate object to indicate whether or not the action succeeded. If successful, the peripheral then calls the
peripheral(_:didUpdateValueFor:error:)
method of its delegate object whenever the characteristic value changes. Because it is the peripheral that chooses when to send an update, your app should be prepared to handle them as long as notifications or indications remain enabled. If the specified characteristic is configured to allow both notifications and indications, calling this method enables notifications only. You can disable notifications and indications for a characteristic’s value by calling this method with the
enabled
parameter set to
false
.