当信标关闭时,我总是被didRange
解雇,即使我打开信标,didEnter
也不会被解雇。 (在信息上设置所有键)
设置信标:
if (CLLocationManager.authorizationStatus() != CLAuthorizationStatus.AuthorizedWhenInUse) {
locationManager.requestWhenInUseAuthorization()
}
let region = CLBeaconRegion(proximityUUID: NSUUID(UUIDString: "74278BDA-B644-4520-8F0C-720EAF059935")!, identifier: "Me")
region.notifyOnEntry=true;
region.notifyOnExit=true;
locationManager.startRangingBeaconsInRegion(region)
locationManager.delegate = self;
locationManager.requestAlwaysAuthorization()
locationManager.requestStateForRegion(region)
代表们:
func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion) {
print("didRangeBeacons"); // keep being called always
func locationManager(manager: CLLocationManager, didEnterRegion region: CLRegion) {
print("enter region"); // never happen
我想让他们两个都被调用,所以我可以检查didRange
内的值,但我也可以只在EnterRegion
<上发送推送/ p>
答案 0 :(得分:2)
显然:)
locationManager.startRangingBeaconsInRegion(region)
仅开始范围, 监视 :
locationManager.startMonitoringForRegion(region)