在applicationDidEnterBackground
或applicationWillResignActive
我需要startAdvertising
但我得到这个错误:iBeacon显示开始应用广告确实进入后台
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");
}
}
任何帮助,将不胜感激..
你能想出一种方法来“绕过”这个“限制”,仍然是应用程序商店批准? – snksnk
从我读到的内容来看,Apple在后台限制了CoreLocation框架的广告。但似乎可以用CoreBluetooth在后台发送BT广告数据。我不知道你是否可以用这种方法获得完整的iBeacon功能,我也不知道苹果是否会在AppStore中批准这个功能......但值得一试。这是一个处理这个问题的GitHub项目https://github.com/Instrument/Vicinity/ – Argent