gpt4 book ai didi

ios - iBeacon 开始在应用程序上转换广告确实进入了后台

转载 作者:行者123 更新时间:2023-11-28 20:01:54 24 4
gpt4 key购买 nike

applicationDidEnterBackgroundapplicationWillResignActive 我需要 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");
}
}

任何帮助将不胜感激..

最佳答案

如果您想从您的应用中主动发送 BT 广告数据,我认为您的应用必须在前台。这是来自 Apple Class Reference

[..]Data advertising is done on a “best effort” basis, because space is limited and there may be multiple apps advertising simultaneously. While your app is in the foreground, it can use up to 28 bytes of space in the initial advertisement data for any combination of the supported advertising data keys[..]

在后台时,您只能收听 信标。为此,您必须将您的应用和信标数据注册到 CLLocationManager

关于ios - iBeacon 开始在应用程序上转换广告确实进入了后台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23655362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com