Beacons做了范围叫但是输入不是吗?

时间:2016-08-07 12:02:56

标签: swift ibeacon

当信标关闭时,我总是被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>

1 个答案:

答案 0 :(得分:2)

显然:)

    locationManager.startRangingBeaconsInRegion(region)

开始范围 监视

     locationManager.startMonitoringForRegion(region)