【问题标题】:Ranging Beacons in iOS 10iOS 10 中的测距信标
【发布时间】:2017-01-13 08:52:46
【问题描述】:

在我的应用程序中,我在 CoreLocation 中使用 Beacon 区域监控。 该应用程序将 2 个邻近 UUID 设置为区域(它们具有不同的 id), 并像下面一样开始测距。

#pragma mark - CLLocationManagerDelegate

(void)locationManager:(CLLocationManager *)manager
didEnterRegion:(CLRegion *)region {
     [self.locationManager requestStateForRegion:(CLBeaconRegion *)region];
}

- (void)locationManager:(CLLocationManager *)manager 
didExitRegion:(CLRegion *)region {
     [self.locationManager stopRangingBeaconsInRegion:(CLBeaconRegion *)region]; 
}

- (void)locationManager:(CLLocationManager *)manager
didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region{ 
    for(CLBeacon* b in beacons){
         //output only previous beacon if it's before regionout to previous region
         NSLog(@"%@",b);
    }
}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
     //error
}

- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region{ 
   if(state == CLRegionStateInside){
        if ([region isMemberOfClass:[CLBeaconRegion class]] && [CLLocationManager isRangingAvailable]){
            [self.locationManager startRangingBeaconsInRegion:(CLBeaconRegion *)region];
        }
  }
}

它适用于 iOS 8 和 iOS 9,但不适用于 iOS 10。

[在 iOS 8/iOS 9 中]

1.broadcast beacon1

2.[app]didRangeBeacons (beacon1)

3.stop beacon1 and broadcast beacon2

4.[app]didRangeBeacons (beacon2)

[iOS 10]

1.broadcast beacon1

2.[app]didRangeBeacons (beacon1)

3.stop beacon1 and broadcast beacon2

4.[app]didRangeBeacons (**beacon1**)

这是 iOS 10 的错误吗?

【问题讨论】:

  • 在 iOS 10 中,信标测距似乎确实有些不同。我得到了非常不一致的结果,信标短暂显示,然后再也没有在 didRangeBeacons 函数中测距。
  • 感谢您的试用和信息!我正在等待更新解决...
  • 您是否为此问题提交了雷达?
  • 也许你应该在 iOS 10.1b2 上试试。我在 iOS 10.0.x 中遇到了不同的信标问题(没有触发区域退出事件)。这个接缝将在最新的 IOS 测试版中修复。
  • 安装 10.0.3 (14A551) 后 iBeacon 问题较少

标签: ios objective-c bluetooth core-location ios10


【解决方案1】:

好的,我在 Swift 3 中遇到了同样的问题,但我解决了。

似乎有两件事(可能直接相关):

  • 对于 iOS10,信标的广告间隔可能设置得太高(将其设置为大约 200 毫秒,然后按照 Macrumors 上 dantastic 的建议,它应该在 9 和 10 上工作)

  • 我如何让它再次工作:我在装有 iOS 9.3.5 的 iPad 上对其进行了测试,需要将部署目标更改为 9.3。这表明它可以在我的装有 iOS 9 的 iPad 上再次运行,但是......也在我的 iOS 10 设备上解决了它。

【讨论】:

    猜你喜欢
    • 2014-12-09
    • 2014-11-09
    • 1970-01-01
    • 2014-02-11
    • 1970-01-01
    • 2019-08-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多