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.
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.
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/
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With