iOS 10中的测距信标 [英] Ranging Beacons in iOS 10

查看:73
本文介绍了iOS 10中的测距信标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我在CoreLocation中使用信标区域监视". 该应用将2个接近UUID设置为区域(它们具有不同的ID), 并开始如下所示.

In my app, I use Beacon Region Monitoring in CoreLocation. The app sets 2 proximityUUID as region (they have different id), and start ranging like following.

#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.

It works in iOS 8 and iOS 9, but it does not work in iOS 10.

[在iOS 8/iOS 9中]

[in 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的错误吗?

Is it a bug of iOS 10?

推荐答案

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

Ok, I had the same problem in Swift 3 but I resolved it.

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

There seem to be two things (that are probably directly related):

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

  • for iOS10 the advertising interval of the beacon might be set too high (set it to about 200ms and then it should work on both 9 & 10 as advised by dantastic on Macrumors)

我如何使其再次工作:我在装有iOS 9.3.5的iPad上对其进行了测试,并且需要将部署"目标更改为9.3.这表明它在装有iOS 9的iPad上都可以再次使用,但是...也可以在iOS 10设备上解决了这个问题.

how I got it working again: I tested it on an iPad with iOS 9.3.5 and needed to change the Deployment target to 9.3. That showed it was working again both on my iPad with iOS 9, but... also resolved it on my iOS 10 devices.

这篇关于iOS 10中的测距信标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆