Curnelious
Curnelious

Reputation: 1

Beacons didRange called but didEnter is not?

When the beacon is off I always get didRange fired, and didEnter is not fired even when I turn on the beacon . (set all keys on info)

Setting the beacon :

    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)

The delegates :

  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

I would like to get both of them called, so I can check the value inside didRange, but I will also be able to send push only on EnterRegion

Upvotes: 2

Views: 349

Answers (1)

Curnelious
Curnelious

Reputation: 1

Obviously :)

    locationManager.startRangingBeaconsInRegion(region)

only start ranging, to monitor you need :

     locationManager.startMonitoringForRegion(region)

Upvotes: 2

Related Questions