didEnterRegion and didExitRegion are not being called

The only thing that really comes to my mind at this point is a bug in iOS. In fact, I’ve experienced something similar with iPhone 4S and iOS 8.0, where my app just couldn’t establish the state no matter how hard I tried. My problem was fixed in iOS 8.1 or 8.2, don’t remember exactly. Maybe this is something similar, could you try opening a bug report with Apple?

well its was the ios version lool…i updated my ipad to ios 9.0.1 and my app and the estimote template works now thx a lot for your help :smile: great community

keep the good work

1 Like

The above topic solved many of my questions. A part of it is working fine. The problems is i have to monitor two regions. whether i have to moniter them individually or both at the same time. Please help

let area = CLBeaconRegion(proximityUUID: NSUUID(UUIDString: "B9407F30-F5F8-466E-AFF9-25556B57FE6D")!, identifier: "bestpals")

# INDIVIDUALLY TWO BEACONS WITH DIFF MINOR ID
let area1 = CLBeaconRegion(proximityUUID: NSUUID(UUIDString: "B9407F30-F5F8-466E-AFF9-25556B57FE6D")!, major:8693, minor:14142, identifier: "blue")
let area2 = CLBeaconRegion(proximityUUID: NSUUID(UUIDString: "B9407F30-F5F8-466E-AFF9-25556B57FE6D")!, major:30160, minor:48293, identifier: "grey")

override func viewDidLoad() {
    super.viewDidLoad()
     
    locationManager.delegate = self
    locationManager.requestAlwaysAuthorization() 

    # HELP NEEDED....WHICH AREA SHOULD BE USED FOR MONITORING........AREA OR AREA1 OR AREA2
    locationManager.startMonitoringForRegion(area)
}
 
func locationManager(manager: CLLocationManager, didStartMonitoringForRegion region: CLRegion) {
    self.locationManager.requestStateForRegion(region)
    c.text  = "moniterd : \(region.identifier)"
}

func locationManager(manager: CLLocationManager, didEnterRegion region: CLRegion) {
    a.text  = "entered region : \(region.identifier)"
}

func locationManager(manager: CLLocationManager, didExitRegion region: CLRegion) {
    b.text = "exited region : \(region.identifier)"
}

func locationManager(manager: CLLocationManager, didDetermineState state: CLRegionState, forRegion region: CLRegion) {
    switch state {
    case .Unknown:
        print("unknown : \(region.identifier)")
        state3.text = "unknown : \(region.identifier)"
    case .Inside:       
        print("inside : \(region.identifier)")
        state1.text = "inside : \(region.identifier)"
    case .Outside:
        print("outside : \(region.identifier)")
        state2.text = "outside : \(region.identifier)"
    }
}

If you want separate enter/exit events for area1 and area2, just start monitoring for both of them:

locationManager.startMonitoringForRegion(area1)
locationManager.startMonitoringForRegion(area2)

but when i run the code only "locationManager.startMonitoringForRegion(area2)” calls… i.e, only area2 get monitored

It might seem that only area2 is being monitored, because you always overwrite the text.

For example, you start monitoring for area1, and didStartMonitoring is called for area1. Text is set to moniterd : blue.

Milliseconds after that, monitoring for area2 starts, and didStartMonitoring is called for area2. The previous text is overwritten and it now says to moniterd : grey.

Same for all the other events.

If you want to verify if both work, you can use NSLog instead:

NSLog("moniterd : \(region.identifier)")

This will log the messages in the Xcode’s console instead, and nothing will be overwritten.

Thank you. kinda helped me…

Hi heypiotr,
I connected the beacon to my phone it work fine, i enter in beacon range it trigger but after 1min didexitrange was trigger, but i am staying same place and also after 1min didenterrange was trigger.

It repeatedly occurred

Hi,

Without Passing the Major / Minor didEnter or didExit not calling. But When I pass the Major - Minor it’s working fine. Can you say I have to pass major/minor for each beacons.

Thanks.

Without major/minor, the smartphone will scan for any beacons with the matching UUID, and as long as there’s at least one in range, won’t trigger an exit.

For example: you have two beacons in range:

  1. UUID X, major 1, minor 1
  2. UUID Y, major 1, minor 2

Case 1: you scan for UUID X + major 1 + minor 1. When beacon #1 leaves range, exit triggers.

Case 2: you scan for UUID X. When beacon #1 leaves range, there’s still beacon #2 matching the criteria, so no exit will be triggered.

Yes, But App in Killed state at that time it’s not working. I set the below configure.

NOT WORKING :

1)

 const region1 = {

 identifier:'Beacons',

 uuid:'F7826DA6-4FA2-4E98-8024-BC5B71E8899E', 

};

2)

 const region1 = {

 identifier:'Beacons',

 uuid:'F7826DA6-4FA2-4E98-8024-BC5B71E8899E', 

 major:1

 };

WORKING :

 const region1 = {

 identifier:'Beacons',

 uuid:'F7826DA6-4FA2-4E98-8024-BC5B71E8899E', 

 major:1,

 minor : 1

 };

i added the NSLocationAlwaysUsageDescription to my info.plist and when i start the app it asks for permission to use the location.