5

I have been doing some reading about CLBeaconRegion and I have setup some iBeacons successfully and had it trigger location updates, even while the application is in the background.

However, from what I've read and carry over from CLRegion, I understand that it should be possible to hit locationManager:didEnterRegion: after the application is terminated.

I've setup my CLBeaconRegion like this:

beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:SERVICE_UUID]
                                                       major:0
                                                       minor:0
                                                  identifier:BEACON_ID];
[beaconRegion setNotifyOnEntry:YES];
[beaconRegion setNotifyOnExit:YES];
[beaconRegion setNotifyEntryStateOnDisplay:YES];

But I am not able to trigger the CLLocationManager's delegate from termination. I've left the region (confirmed by a notification), travelled further away from the beacon, waited for 30 seconds, then travelled back to the beacon, but it does not trigger the delegate while terminated (works great while in the background and foreground).

Should this work from termination? Am I missing something? Any help would be great.

RileyE
  • 10,874
  • 13
  • 63
  • 106

4 Answers4

4

I believe that when you are in the background or not running, it calls locationManager:didDetermineState:forRegion: instead of locationManager:didEnterRegion:, and then only if you've set notifyEntryStateOnDisplay to TRUE.

Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • In the background, it still calls `locationManager:didEnterRegion:`, as `locationManager:didDetermineState:forRegion:`, however, from my testing, it will not call either from a terminated state (user swiping the application up). I do have `notifyEntryStateOnDisplay` set to `YES`/`TRUE`, as well. – RileyE Oct 23 '13 at 22:31
1

EDIT: The below is no longer true as of 7.1. You can still receive notifications even when the application has closed

The behavior of applications being swiped away in the application switcher now has the effect you're describing under iOS 7.

Users who remove your application from the switcher have made a decision to not allow your app to run in the background. Thus, region monitoring will not re-open your application.

Check out the "What’s New with Multitasking" session from WWDC 2013 for more information.

mattyohe
  • 1,814
  • 12
  • 15
1

This is the expected behavior on iOS 7. However, this behavior has been changed under iOS 7.1. iOS 7.1 reverts delegate calls back to pre-iOS 7 behavior.

I've documented this behavior in a blog post of mine.

http://www.simplymadeapps.com/blog/2014/03/7-1-brings-back-geofence-behavior/

Bill Burgess
  • 14,054
  • 6
  • 49
  • 86
-1

Yeah,

 Same behaviour is being noticed .Sometimes even while calling setNotifyEntryStateOnDisplay, didEnterRegion not called even when in foreground.
shubham jain
  • 156
  • 1
  • 9