Xcode 8.0 Cbcentralmanager Issue

Xcode 8.0 CBCentralManager Issue

The simplest approach is just to use the short-hand reference to the enumeration value:

func centralManagerDidUpdateState(central: CBCentralManager)
{
print("state is \(central.state.rawValue)")
if (central.state == .PoweredOn)
{
self.centralManager?.scanForPeripheralsWithServices([serviceUUID], options: nil)
}
else
{
// do something like alert the user that ble is not on
}

}

Now your code will compile without errors or warnings and works correctly on all targets

CBCentralManager iOS10 and iOS9

I contacted Apple about this and was given the following response (paraphrasing).

Due to the changing nature of swift, the above implementation is not possible however you can use the rawValue of the enum as the state is identical between the two classes. Therefore the following will work for now:

func centralManagerDidUpdateState(_ central: CBCentralManager) {
if #available(iOS 10.0, *) {
switch central.state{
case CBManagerState.unauthorized:
print("This app is not authorised to use Bluetooth low energy")
case CBManagerState.poweredOff:
print("Bluetooth is currently powered off.")
case CBManagerState.poweredOn:
print("Bluetooth is currently powered on and available to use.")
default:break
}
} else {
// Fallback on earlier versions
switch central.state.rawValue {
case 3: // CBCentralManagerState.unauthorized :
print("This app is not authorised to use Bluetooth low energy")
case 4: // CBCentralManagerState.poweredOff:
print("Bluetooth is currently powered off.")
case 5: //CBCentralManagerState.poweredOn:
print("Bluetooth is currently powered on and available to use.")
default:break
}
}
}

CBPeripheralManager is not powered on

You need to wrap all your calls to the CBPeripheralManager inside a state check in order to prevent these warnings. Since you are just calling advertise at an undetermined time later, you need to ensure your peripheralManager is still powered and ready to go.

- (IBAction)advertise:(id)sender
{
if(self.peripheralManager.state == CBPeripheralManagerStatePoweredOn)
{
//Now you can call advertise
}
}

Can I upload iOS App to AppStore using Xcode 8.2, even if apple has release Xcode 8.3 and iOS 10.3

As stated here and here, any version from Xcode 6.0 and over, regardless of which language (and language version) you use, will do.

iOS 8 CoreBluetooth deprecated RSSI methods

There is a known issue that has been posted about this on the Apple Developer forums to which I have an open radar as well.

The issue seems to be that the new callback method peripheral:didReadRSSI:error: is never called on iOS 8 specifically after the initial connection is made to a peripheral. The only resolution I have found is to reset bluetooth on your phone by turning it on/off or restarting the phone.

Here is the link to open radar I filed.

UPDATE:

Just tested my example that was displaying this issue with the current 8.2 release and I am no longer seeing any issues with the new iOS 8 delegate method never being called. I am marking my radar as resolved per the 8.2 release.



Related Topics



Leave a reply



Submit