gpt4 book ai didi

ios - ibeacon 将无法工作

转载 作者:行者123 更新时间:2023-11-28 19:48:57 24 4
gpt4 key购买 nike

info.plist 中:

我们添加了 NSLocationAlwaysUsageDescription。在所需的后台模式上,我们添加了所有蓝牙内容(通过蓝牙通信和共享数据)和位置 - “register for location updates”

我们已经导入了位置和蓝牙框架,以及基础。

我们用这个启动蓝牙:

  if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
{
[self.locationManager requestAlwaysAuthorization];
}



self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;



self.beaconRegion.notifyOnEntry=YES;
self.beaconRegion.notifyOnExit=YES;
self.beaconRegion.notifyEntryStateOnDisplay=YES;
[self.locationManager requestAlwaysAuthorization ];
[self.locationManager requestWhenInUseAuthorization];



NSUUID *uuid_in = [[NSUUID alloc] initWithUUIDString:uuid];
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid_in identifier:@"com.name.us"];
[self.locationManager startMonitoringForRegion:self.beaconRegion];

代表被称为:

- (void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region {

NSLog(@"started:%@",region);
//[self.locationManager requestStateForRegion:self.beaconRegion];

self.beaconRegion.notifyEntryStateOnDisplay=YES;

}

问题是当我们打开硬件信标(它正在与其他应用程序一起工作检查)时,代表没有被调用(iPhone6):

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region {

最佳答案

一些提示:

  1. 你应该只做这两个中的一个。如果你有第一行,就去掉第二行。 (你也有上面重复的相同的第一行。)

    [self.locationManager requestAlwaysAuthorization ];[self.locationManager requestWhenInUseAuthorization];

  2. 不需要特殊的背景模式。

  3. 不需要蓝牙框架。

  4. 您正在修改您的 CLBeaconRegion,然后再对其进行初始化。以 self.beaconRegion.notifyOnEntry=YES; 开头的行需要向下移动到初始化之后。

  5. 确保 uuid_in 中定义的 ProximityUUID 与您的信标实际匹配。请发布其初始化方式的代码,以便我们确定。

  6. 尝试卸载并重新安装您的应用。确保在首次启动时收到位置权限提示并接受。如果您没有收到提示,则说明有问题。

关于ios - ibeacon 将无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30326106/

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