gpt4 book ai didi

ios - iOS 10 中的测距信标

转载 作者:可可西里 更新时间:2023-11-01 03:20:41 24 4
gpt4 key购买 nike

在我的应用中,我在 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/

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