我现在正在试用 iBeacons。
我有 2 台设备用作信标,还有 1 台设备用于测距。
当我实现此方法调用 locationManager:didRangeBeacons:inRegion: 时,在文档中它说“didRangeBeacons”在附近接收一组信标。
但是,我注意到 locationManager:didRangeBeacons:inRegion: 被每个单独的信标调用两次。它应该表现得那样吗?
谢谢,
三通
我现在正在试用 iBeacons。
我有 2 台设备用作信标,还有 1 台设备用于测距。
当我实现此方法调用 locationManager:didRangeBeacons:inRegion: 时,在文档中它说“didRangeBeacons”在附近接收一组信标。
但是,我注意到 locationManager:didRangeBeacons:inRegion: 被每个单独的信标调用两次。它应该表现得那样吗?
谢谢,
三通
您应该每秒对您正在测距locationManager:didRangeBeacons:inRegion
的每个 对象进行一次调用,并且此回调包括在该区域内看到CLBeaconRegion
的对象数组。CLBeacon
因此,如果您设置了两个CLBeaconRegion
对象并在它们上进行测距,则您应该每秒进行两次回调,每个回调在其数组中都有一个信标。
如果您设置了一个CLBeaconRegion
与两个信标匹配的测距,那么您应该每秒只收到一个回调,并且它的数组中应该包含两个信标。
You're right that locationManager:didRangeBeacons:inRegion
gets called multiple times - when the proximity of beacons changes. I thought I read that this was usually once per second (and my testing would seem to align with this) but I can't find a reference for it at the moment.
You can of course decide what action you want to take whenever the method gets called (or even to take no action at all). You could also call stopRangingBeaconsInRegion:
if you only want to be notified once.