-[CLLocationManager monitoredRegions] is always empty, broken and monitored regions are not preserved between app launches

Originator:fabian
Number:rdar://20121119 Date Originated:03/11/2015
Status:Closed Resolved:Yes
Product:OS X Product Version:10.10.2
Classification:Other Bug Reproducible:Always
 
Summary:
Region monitoring using CLLocationManager doesn’t work as expected. Specifically, -monitoredRegions always returns an empty set and monitored regions are not preserved between app launches.
Region monitoring works fine while the app is running, even when the Mac is put to sleep, but it doesn’t work when the app is quit, the Mac moves and the app is then relaunched.

Use-case:
1. User opens the app, sets up a geofence
2. User quits the app
3. User moves to another location that would trigger a region change
4. User launches the app
—> The app doesn’t get notified about the region change although it monitored the region

Steps to Reproduce:
1. Monitor a region using -[CLLocationManager startMonitoringForRegion:]
2. Wait and observe -[CLLocationManager monitoredRegions]
—> The returned set is always empty, although it should contain the region monitored in step 1.
3. Quit the app
4. Launch the app
—> -monitoredRegions should include the previously monitored region (as it says in the docs), but it’s empty as before

Expected Results:
1. -monitoredRegions should contain the regions added with -startMonitoringForRegion:
2. Monitored regions should be preserved between app launches and -monitoredRegions needs to include regions added in a previous app run

Actual Results:
- [CLLocationManager monitoredRegions] always returns an empty set containing not a single region.

Version:
Mac OS X 10.10.2 (14C1510)

Notes:
Workaround:
The only workaround is to save the latest known location and compare it with the current location on app launch.
This is bad for several reasons: Privacy and security, additional complexity, always need to query the current location, etc.

Regression:
I guess it works fine on iOS, but I haven’t tested it thoroughly there.

Configuration:
Mac OS X 10.10.2, Xcode 6.1.1

Attachments:
'MonitoredRegions.zip' was successfully uploaded.

Comments

Fixed in 10.11 beta 6


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!