Skip to content

Commit

Permalink
Address iOS deprecation warnings & general warnings (#919)
Browse files Browse the repository at this point in the history
peitschie committed Jul 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 2ce4c56 commit bfab8c1
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/ios/BLECentralPlugin.m
Original file line number Diff line number Diff line change
@@ -63,12 +63,12 @@ - (void)pluginInitialize {
stopNotificationCallbacks = [NSMutableDictionary new];
l2CapContexts = [NSMutableDictionary new];
bluetoothStates = [NSDictionary dictionaryWithObjectsAndKeys:
@"unknown", @(CBCentralManagerStateUnknown),
@"resetting", @(CBCentralManagerStateResetting),
@"unsupported", @(CBCentralManagerStateUnsupported),
@"unauthorized", @(CBCentralManagerStateUnauthorized),
@"off", @(CBCentralManagerStatePoweredOff),
@"on", @(CBCentralManagerStatePoweredOn),
@"unknown", @(CBManagerStateUnknown),
@"resetting", @(CBManagerStateResetting),
@"unsupported", @(CBManagerStateUnsupported),
@"unauthorized", @(CBManagerStateUnauthorized),
@"off", @(CBManagerStatePoweredOff),
@"on", @(CBManagerStatePoweredOn),
nil];
readRSSICallbacks = [NSMutableDictionary new];
}
@@ -353,14 +353,14 @@ - (void)stopNotification:(CDVInvokedUrlCommand*)command {

- (void)isEnabled:(CDVInvokedUrlCommand*)command {
CDVPluginResult *pluginResult = nil;
int bluetoothState = [manager state];
CBManagerState bluetoothState = [manager state];

BOOL enabled = bluetoothState == CBCentralManagerStatePoweredOn;
BOOL enabled = bluetoothState == CBManagerStatePoweredOn;

if (enabled) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:bluetoothState];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsNSInteger:bluetoothState];
}
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
@@ -446,8 +446,8 @@ - (void)startStateNotifications:(CDVInvokedUrlCommand *)command {

if (stateCallbackId == nil) {
stateCallbackId = [command.callbackId copy];
int bluetoothState = [manager state];
NSString *state = [bluetoothStates objectForKey:[NSNumber numberWithInt:bluetoothState]];
CBManagerState bluetoothState = [manager state];
NSString *state = [bluetoothStates objectForKey:@(bluetoothState)];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:state];
[pluginResult setKeepCallbackAsBool:TRUE];
NSLog(@"Start state notifications on callback %@", stateCallbackId);
@@ -689,7 +689,7 @@ - (void)centralManagerDidUpdateState:(CBCentralManager *)central
{
NSLog(@"Status of CoreBluetooth central manager changed %ld %@", (long)central.state, [self centralManagerStateToString: central.state]);

if (central.state == CBCentralManagerStateUnsupported)
if (central.state == CBManagerStateUnsupported)
{
NSLog(@"=============================================================");
NSLog(@"WARNING: This hardware does not support Bluetooth Low Energy.");
@@ -1234,21 +1234,21 @@ -(void) cleanupOperationCallbacks: (CBPeripheral *)peripheral withResult:(CDVPlu

#pragma mark - util

- (NSString*) centralManagerStateToString: (int)state {
- (NSString*) centralManagerStateToString: (CBManagerState)state {
switch(state)
{
case CBCentralManagerStateUnknown:
return @"State unknown (CBCentralManagerStateUnknown)";
case CBCentralManagerStateResetting:
return @"State resetting (CBCentralManagerStateUnknown)";
case CBCentralManagerStateUnsupported:
return @"State BLE unsupported (CBCentralManagerStateResetting)";
case CBCentralManagerStateUnauthorized:
return @"State unauthorized (CBCentralManagerStateUnauthorized)";
case CBCentralManagerStatePoweredOff:
return @"State BLE powered off (CBCentralManagerStatePoweredOff)";
case CBCentralManagerStatePoweredOn:
return @"State powered up and ready (CBCentralManagerStatePoweredOn)";
case CBManagerStateUnknown:
return @"State unknown (CBManagerStateUnknown)";
case CBManagerStateResetting:
return @"State resetting (CBManagerStateUnknown)";
case CBManagerStateUnsupported:
return @"State BLE unsupported (CBManagerStateResetting)";
case CBManagerStateUnauthorized:
return @"State unauthorized (CBManagerStateUnauthorized)";
case CBManagerStatePoweredOff:
return @"State BLE powered off (CBManagerStatePoweredOff)";
case CBManagerStatePoweredOn:
return @"State powered up and ready (CBManagerStatePoweredOn)";
default:
return @"State unknown";
}

0 comments on commit bfab8c1

Please sign in to comment.