title: iOS/Swift/CoreBluetooth Ble Notifications not working
body: <p>I have a problem where I connect to a peripheral and set notify value to true correctly but I can't get the value. I am following the next steps.</p>
  
  <p>1 - I connect to peripheral </p>
  
  <p>2 - I discover services</p>
  
  <p>3 - I discover characteristics for services</p>
  
  <p>4 - I activate notifications for a specific characteristic </p>
  
  <pre><code>override func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
           if characteristic.uuid == historicCharacteristicCBUUID &amp;&amp; characteristic.properties.contains(.notify) {
                          print("\(characteristic.uuid): properties contains .notify")
                          if hasWritenOnHistoric == false {
                              peripheral.setNotifyValue(true, for: characteristic)
                          }
                      } 
  }
  </code></pre>
  
  <p>5 - I wait to the delegate and then write on the characteristic to tell the peripheral to start sending data</p>
  
  <pre><code>override func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: Error?) {
          print(characteristic)
          if error == nil {
              print("TRUE")
              if characteristic.uuid == historicCharacteristicCBUUID &amp;&amp; characteristic.isNotifying == true {
                  writeOnHistory(peripheral: peripheral, characteristic: characteristic)
              } else {
                  print("no ha cambiado su estado")
              }
          }
      }
  </code></pre>
  
  <p>6 - Write on peripheral</p>
  
  <pre><code>func writeOnHistory(peripheral: CBPeripheral, characteristic: CBCharacteristic) {
          if characteristic.uuid == historicCharacteristicCBUUID {
              hasWritenOnHistoric = true
              var bitesArray: [UInt8] = [0x01, 0x05]
  
              for _ in 1...16 {
                  bitesArray.append(0x00)
              }
  
              print(bitesArray.count)
              print(bitesArray)
              let data = Data(bytes: bitesArray)
              peripheral.writeValue(data, for: characteristic, type: .withResponse)
          }
      }
  </code></pre>
  
  <p>7 - This delegate is only called once and with empty data [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00](in Android is working fine getting all the data from the peripheral)</p>
  
  <pre><code>override func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
              if let data = characteristic.value {
              print(data)
              }
          }
  </code></pre>
  
  <p>Is there something I am missing?</p>
  
  <p>Thanks in advance!</p>