Upon applicationDidEnterBackground
or applicationWillResignActive
I need to startAdvertising
but I get this error:
CoreBluetooth[API MISUSE] <CBPeripheralManager: 0x146a4e30> can only accept this command while in the powered on state.
I use:
- (void)applicationWillResignActive:(UIApplication *)application
{
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
[_locationManager stopRangingBeaconsInRegion:_runningBeacon];
NSLog(@"stop monitoring");
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"23542266-18D1-4FE4-B4A1-23F8195B9D39"];
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid major:1 minor:1 identifier:@"com.devfright.myRegion"];
self.beaconPeripheralData = [self.beaconRegion peripheralDataWithMeasuredPower:nil];
self.peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil options:nil];
[self.peripheralManager startAdvertising:self.beaconPeripheralData];
if ([self.peripheralManager isAdvertising]) {
NSLog(@"peripeheralManager is advertising");
}
}
Any help would be appreciated..