Skip to content

Commit

Permalink
fix(ios): fix service being nullable in new CBCharacteristic (xcode 1…
Browse files Browse the repository at this point in the history
…3) (#197)

* Work around for #196

This works around the changes in the iOS 15 API, issue #196

* fix(ios): do not use optional chaining for service

Co-authored-by: pwespi <[email protected]>
  • Loading branch information
squio and pwespi authored Sep 22, 2021
1 parent dd69e70 commit 469c6eb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ios/Plugin/Device.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,13 @@ class Device: NSObject, CBPeripheralDelegate {
}

private func getKey(_ prefix: String, _ characteristic: CBCharacteristic) -> String {
let serviceUUIDString = cbuuidToStringUppercase(characteristic.service.uuid)
let serviceUUIDString: String
let service: CBService? = characteristic.service
if service != nil {
serviceUUIDString = cbuuidToStringUppercase(service!.uuid)
} else {
serviceUUIDString = "UNKNOWN-SERVICE"
}
let characteristicUUIDString = cbuuidToStringUppercase(characteristic.uuid)
return "\(prefix)|\(serviceUUIDString)|\(characteristicUUIDString)"
}
Expand Down

0 comments on commit 469c6eb

Please sign in to comment.