または必要がありますがapplicationDidEnterBackground
、次のエラーが発生します。applicationWillResignActive
startAdvertising
CoreBluetooth[API MISUSE] <CBPeripheralManager: 0x146a4e30> can only accept this command while in the powered on state.
私が使う:
- (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");
}
}
どんな助けでも大歓迎です..