當使用簡單應用測試信標區域監控時,我似乎根據設備(不是設備型號,特定設備)得到非常不一致的結果。問題是,在requestStateForRegion
和didEnterRegion
在這些設備上根本沒有被調用之後,我沒有收到該區域的CLRegionStateInside
狀態。 startRangingBeaconsinRegion
:工作正常,但爲了節省電力並處理它,建議只在didEnterRegion
:方法被調用時纔開始測距。我在6臺設備上進行了測試,並且它在一半(iPhone 5)上工作,並且不適用於一臺iPhone 5,一臺5S
和一臺4S
。IBeacon區域監控在設備間不一致工作
我使用的信標是kontakt.io
信標。
這是代碼來設置區域監測
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:BEACON_UUID];
CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid
identifier:@"regionIdentifier"];
region.notifyOnEntry = YES;
region.notifyOnExit = YES;
region.notifyEntryStateOnDisplay = YES;
[self.locationManager startMonitoringForRegion:region];
[self.locationManager requestStateForRegion:region];
//If I enable this line, ranging starts on all devices
// [self.locationManager startRangingBeaconsInRegion:region];
我相信你應該叫[_locationManager startMonitoringForRegion:區域]。不是startRangingBeaconsInRegion :. – Greg
我確實會調用該方法,因爲您可以在我的帖子中看到。解決方案是讓用戶啓用後臺刷新,正如我在我的回答中提到的 – TimPelgrim