cordova-plugin-ble-central
cordova-plugin-ble-central copied to clipboard
retrievePeripheralWithUUID crashing if uuid not valid
If you attempt to connect to an invalid BLE address the app crashes on iOS. Added the 2 lines below for a nil check to resolve it .
This is for version 143.
- (CBPeripheral*)retrievePeripheralWithUUID:(NSString*)uuid {
NSUUID *typedUUID = [[NSUUID alloc] initWithUUIDString:uuid];
// FIX CRASH FOR INVALID UUID
if (typedUUID == nil)
return(nil);
NSArray *existingPeripherals = [manager retrievePeripheralsWithIdentifiers:@[typedUUID]];
CBPeripheral *peripheral = nil;
if ([existingPeripherals count] > 0) {
peripheral = [existingPeripherals firstObject];
[peripherals addObject:peripheral];
}
return peripheral;
}
Good pickup! I'll put it on my list... patches welcome however if you have the time & expertise to assist.