CBCentralManger Delegate method behaves differently in iOS 11 and below iOS 11
Below iOS 11: After updating the CBCentralMangaer state to CBManagerStatePoweredOff state CentralManager delegate -(void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error is calling and connected peripheral will get disconnect.
iOS 11 After updating the CBCentralMangaer state to CBManagerStatePoweredOff state central manager disconnect delegate didDisconnectPeripheral is not calling.
I want disconnect delegate should invoked in iOS 11, So How can I resolve this issue in iOS 11.
You are correct that the API behavior changed between iOS 10 and iOS 11 in regards to bluetooth state changes. Unfortunately there is nothing you can do to change this.
However, the best way to work around this is to add your own logic in the centralManagerDidUpdateState: callback. There you can check if the new state is CBManagerStatePoweredOff and you are running iOS 11 or above. If that is the case then just do whatever you need to do, update UI or similar.
- (void)centralManagerDidUpdateState:(CBCentralManager *)central;
{
if (central.state == CBManagerStatePoweredOff && @available(iOS 11, *))
{
// Do the same stuff that you would do in didDisconnectPeripheral: on iOS 10.
}
}