Skip to content

Commit

Permalink
Added guard to peripheral:didUpdateNotificationStateForCharacteristic…
Browse files Browse the repository at this point in the history
…:error: that checks if charcteristic.value is non-nil (plugin crashes if value is nil).
  • Loading branch information
Mikael Kindborg committed Dec 16, 2015
1 parent 247af97 commit 55456d4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ios/EVOBLE.m
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,11 @@ - (void) peripheral: (CBPeripheral *)peripheral
didUpdateNotificationStateForCharacteristic: (CBCharacteristic *)characteristic
error: (NSError *)error
{
[self peripheral:peripheral didUpdateValueForCharacteristic:characteristic error:error];
// Call didUpdateValueForCharacteristic only when we have a value.
if (characteristic.value)
{
[self peripheral:peripheral didUpdateValueForCharacteristic:characteristic error:error];
}
}

- (void)peripheral:(CBPeripheral *) peripheral
Expand Down Expand Up @@ -1173,6 +1177,8 @@ - (void) enableNotification: (CDVInvokedUrlCommand*)command
if (nil == characteristic) return; // Error.

// Result is delivered in:
// peripheral:didUpdateValueForCharacteristic:error:
// TODO Confirm this: Possibly results are also delived in:
// peripheral:didUpdateNotificationStateForCharacteristic:error:
[myPeripheral
addCallbackForCharacteristic: characteristic
Expand Down

0 comments on commit 55456d4

Please sign in to comment.