【问题标题】:iBeacon and iOS 9iBeacon 和 iOS 9
【发布时间】:2016-02-01 13:07:38
【问题描述】:

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

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

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

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

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

A few people complained about something similar on Apple Dev Forums,但 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];

【问题讨论】:

  • 你的应用的目的是什么?
  • @MihirOza 是否相关?它在 NDA 下,我不能谈论它。
  • 您是否尝试过使用不同的 .desiredAccuracy 精度?
  • @UlyssesR 影响位置更新,而不是信标测距。位置更新的唯一目的是让应用在后台保持“感知”(“位置更新”后台模式开启),以便调用 CLLocationManagerdelegate 方法。
  • 您是否尝试过运行可以检测和配置信标的第三方应用程序?看看他们是否也无法检测到相同的信标会很有趣。

标签: ios bluetooth core-location ibeacon


【解决方案1】:

我认为在您使用地理围栏或 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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-02
    • 2013-09-30
    • 1970-01-01
    • 1970-01-01
    • 2015-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多