Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continuously Showing "Turn on Bluetooth to allow app to connect to accessories" alert message in background in ios

I am using iBeacon Technology in my application. I'm checking in the app whether the bluetooth is enabled or disable by the user and for that i have written code below.

 - (void)viewDidLoad 
 {
  [super viewDidLoad];
  _bluetoothManager =  [[CBCentralManager alloc] initWithDelegate:self queue:nil options:nil];
}

  // bluetooth manager state change
  - (void)centralManagerDidUpdateState:(CBCentralManager *)central
 {
 NSString *stateString = nil;
 switch(central.state)
 {
    case CBCentralManagerStateResetting: stateString = @"The connection with the system service was momentarily lost, update imminent."; break;
    case CBCentralManagerStateUnsupported: stateString = @"The platform doesn't support Bluetooth Low Energy."; break;
    case CBCentralManagerStateUnauthorized: stateString = @"The app is not authorized to use Bluetooth Low Energy."; break;
    case CBCentralManagerStatePoweredOff: stateString = @"Bluetooth is currently powered off."; break;
    case CBCentralManagerStatePoweredOn: stateString = @"Bluetooth is currently powered on and available to use."; break;
    default: stateString = @"State unknown, update imminent."; break;
  }
 }

enter image description here

Problem : This above alert Message prompts very oftenly in background or when the other app is open even if i have kill the application. I want to show this default alert message but only when the user opens the app.

Can anyone provide me a solution?

like image 932
Arpit Avatar asked Nov 16 '25 05:11

Arpit


1 Answers

self.bluetoothManager = [[CBCentralManager alloc] initWithDelegate:self
                                                             queue:nil
                                                           options:@{CBCentralManagerOptionShowPowerAlertKey: @NO}];

This maybe works to hide the system pop up.

like image 90
Rain Avatar answered Nov 18 '25 19:11

Rain