Simón Internacional Simón Internacional - 6 months ago 174
iOS Question

Any way to turn on bluetooth programmatically on iOS7+

I hear that iOS7 introduced this functionality with CBCentralManager but can't find how. Is possible? There is another way widthout use GKPeerPickerController?

Answer

No, if the user has turned off Bluetooth all you can do is display an alert or message asking them to turn it on.

- (void)centralManagerDidUpdateState:(CBCentralManager *)central {

    if (central.state == CBCentralManagerStatePoweredOff) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Error" message: @"Please turn on Bluetooth in Settings" delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
       [alert show]; 
    }
 }