ios - iOS 10 中的测距信标

标签 ios objective-c bluetooth core-location ios10

在我的应用中,我在 CoreLocation 中使用 Beacon Region Monitoring。 该应用程序将 2 个 proximityUUID 设置为区域(它们具有不同的 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 的错误吗?

最佳答案

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

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

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

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

关于ios - iOS 10 中的测距信标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39339835/

相关文章:

objective-c - 带有 NSStrings containstObject 的 NSSet 在应该时不返回 YES

c# - 如何以编程方式配对蓝牙设备

android - Adobe AIR for Android - 打开 native Facebook 应用程序

ios - App分布式临时版本和发行版本

ios - Swift:使用完成处理程序从另一个 ViewController 通知

c# - 在android和c#中读取/发送数据蓝牙通信: c# <-> Android

ios - iOS 中的 WebBLE 支持

objective-c - MapKit 出现 GMMGeoTileImageData 错误

ios - 添加到mapkit时如何自动选择注释

ios - 使用 addSubView 将 View 添加到另一个 View 后调整 View 大小