繁体   English   中英

iBeacon和iOS 9

[英]iBeacon and iOS 9

我目前正在开发需要iBeacon监控的应用程序。

我一年前使用iOS 8.x SDK编写了该应用程序。 它按照预期的那样工作,但是现在,一年之后,相同的代码不再起作用(我正在使用相同的信标进行测试!)。

信标区域检测变得更加不可预测。 它有自己的意志。

有些信标被检测到,有些则被忽略

我在OpenRadar上找不到任何相关内容。

一些人在Apple Dev论坛上抱怨类似的事情 ,但是Apple从来没有回来。

有什么想法吗?

这就是我初始化位置管理器的方式。

self.locationManager = [CLLocationManager new];
self.locationManager.delegate = self;

// Worst accuracy is set in order to preserve battery life.

self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
self.locationManager.allowsBackgroundLocationUpdates = YES;

// Required to keep the app living in the background.
// Background mode "Location Updates" is enabled.

[self.locationManager startUpdatingLocation];

我想在您使用地理围栏或CLCircular区域之前。 核心位置不需要任何代码即可检测iBeacons。 尝试像这样设置:

self.locationManager = [CLLocationManager new];
self.locationManager.delegate = self;
[self.locationManager startMonitoringForRegion:beaconRegion]; // Where "beaconRegion" is a CLBeaconRegion with a UUID that matches the beacon you want to detect (major & minor optional)
beaconRegion.notifyEntryStateOnDisplay = YES;
beaconRegion.notifyOnEntry = YES;
beaconRegion.notifyOnExit = YES;

您还需要将NSLocationAlwaysUsageDescription添加到info.plist。 完成所有操作后,您应该通过以下两种方法开始获取信标的进入和退出事件:

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region;
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM