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

0 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];
Run Code Online (Sandbox Code Playgroud)

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

// 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];
Run Code Online (Sandbox Code Playgroud)

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

-

如果您知道如何使用ESTBeaconRegion和startRangingBeaconsInRegion添加和检测多个信标,我将非常感谢一个代码示例,它解释了如何执行此操作.

dav*_*ung 5

轻松修复!您identifier: @"EstimoteSampleRegion"]必须为所有三个区域使用不同的字符串.

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

无耻的插件:如果您使用我公司的ProximityKit框架,您不必在代码中管理您的信标区域 - 您可以在云中动态地执行此操作.然后,您再也不必担心保持此标识符的唯一性.它与Estimote信标以及所有标准iBeacon兼容.