在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