ios - Estimote:使用 ESTBeaconRegion 和 startRangingBeaconsInRegion 检测多个信标?

标签 ios ibeacon estimote

初学者 Estimote 问题:添加多个 Estimote 信标及其各自的主要/次要信标的正确方法是什么,以便可以使用 startRangingBeaconsInRegion 单独检测所有信标?

此代码适用于单个信标:

// Single Beacon Region
ESTBeaconRegion* beaconRegion = [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID
                                                                    major:11111 minor:11111
                                                                    identifier: @"EstimoteSampleRegion"];
// Start ranging beacons
[self.beaconManager startRangingBeaconsInRegion:beaconRegion];

但是此代码不适用于多个信标:

// Beacon 1 Region
ESTBeaconRegion* beacon1Region = [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID
                                                                    major:11111 minor:11111
                                                                    identifier: @"EstimoteSampleRegion"];
// Beacon 2 Region
ESTBeaconRegion* beacon2Region = [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID
                                                                    major:22222 minor:22222
                                                                    identifier: @"EstimoteSampleRegion"];
// Beacon 3 Region
ESTBeaconRegion* beacon3Region = [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID
                                                                    major:33333 minor:33333
                                                                    identifier: @"EstimoteSampleRegion"];
// Start ranging beacons
[self.beaconManager startRangingBeaconsInRegion:beacon1Region];
[self.beaconManager startRangingBeaconsInRegion:beacon2Region];
[self.beaconManager startRangingBeaconsInRegion:beacon3Region];

使用此代码仅检测到最后一个信标。 (所以在这种情况下,只检测到 beacon3Region)。

如果您知道如何使用 ESTBeaconRegion 和 startRangingBeaconsInRegion 添加和检测多个信标,我将不胜感激解释如何执行此操作的代码示例。

最佳答案

轻松修复!您的标识符:@"EstimoteSampleRegion"] 必须对所有三个区域使用不同的字符串。

无论是使用 Estimote SDK 还是标准 iOS CoreLocation API 都是如此,Estimote SDK 只是一个薄包装。 CoreLocation 使用该字符串标识符作为键来跟踪多个区域。如果多次使用同一个字符串,实际上是在告诉 CoreLocation 用另一个区域替换一个区域。

无耻外挂:如果你用我公司的ProximityKit框架,您根本不必在代码中管理您的信标区域——您可以在云中动态地这样做。然后,您不必再担心保持此标识符的唯一性。它也与 Estimote 信标以及所有标准 iBeacon 兼容。

关于ios - Estimote:使用 ESTBeaconRegion 和 startRangingBeaconsInRegion 检测多个信标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22325079/

相关文章:

android - 安装 Estimote SDK for Android

ios - google 是否在 googlesignin sdk v5.0.1 中删除了 UIWebView 的使用?

ios - 如果我必须下载 image.png 和 image@2x.png 从服务器上传到哪里?

objective-c - 数组不显示值

ios - 即使在后台也能找到 iBeacon 上的调用 Web 服务

android - 如何使用 estimote beacon android 在没有 UUID 的情况下开始测距?

ios - 错误 : Argument type 'Date?' does not conform to expected type 'ReferenceConvertible'

ios - 如何增加准确度计算的时间?

ios - 如何在 Objective-C 中使用 startMonitoringForRegion 扫描多个区域

ios - 估计信标无法按预期在 iPhone 上工作