iOS 10中的Ranging Beacons

8

在我的应用程序中,我使用CoreLocation中的Beacon区域监控。应用程序设置了2个不同ID的ProximityUUID作为区域,并像以下方式一样开始范围测量。

#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是否有bug?


2
在iOS 10中,信标范围似乎有所不同。我发现在didRangeBeacons函数中,信标会短暂地出现,然后再也没有范围变化,结果非常不一致。 - davidethell
你为这个问题提交了雷达反馈吗? - Thomas Einwaller
2
也许你应该尝试使用iOS 10.1b2版本。我在iOS 10.0.x上遇到了不同的信标问题(没有触发区域退出事件)。这似乎已经在最新的IOS测试版中得到了修复。 - patrickS
1
我在安装了10.0.3 (14A551)之后,iBeacon问题减少了。 - Philip Jespersen
@patrickS,@Philip Jespersen:感谢您的信息。看起来问题已经解决了。我检查了我的应用程序在iOS 10.1上可以正常工作。很抱歉确认晚了。 - t_ms
显示剩余2条评论
1个回答

0

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

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

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

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接