locationManager:didEnterRegion: is not called unless app is in the foreground

Originator:imabuddha
Number:rdar://18717530 Date Originated:10/21/2014
Status:open Resolved:
Product:iOS Product Version:8.1 (12B411)
Classification:Serious Bug Reproducible:Always
 
Summary:
Our company has developed an app that requires iOS >= 8 as it uses several new features including action notifications. The app needs to detect the presence of specific iBeacons in any running state (foreground/background/not running). The app is properly configured for this usage. (CLBeaconRegion properties notifyOnEntry, notifyOnExit and notifyEntryStateOnDisplay are set to true. "Location Updates" as a background mode is enabled so that I can receive delegate events when the application is even killed.)
 
It has been working perfectly for the last 3 weeks on iOS 8.0/8.02, but after I installed the 8.1 OTA update on my iPhone 6+ today it will only receive the didEnterRegion notification when running in the foreground. If it's in the background, not running, or the device is locked then no region notifications are received.
 
Although I had been using the 8.0 betas before the official release I haven't used any of the 8.1 betas.

Your AirLocate sample app (properly updated for the iOS 8 location privacy changes) exhibits the same behavior on iOS 8.1. I suggest using it to reproduce the issue.

Steps to Reproduce:
The following requires 2 iPhones:

1. Update AirLocate sample app to be iOS 8+ compliant.
2. On both iPhones install the AirLocate app & ensure that bluetooth turned on.
3. Run the on both phones app & give permission for notifications & location access.
4. On the first iPhone tap Monitoring, then make sure the Notify Entry & Enabled sliders, are on, then tap Save.
5. Put the app into the background by pressing the home button 
6. On the second iPhone tap Configuration, then the Enabled slider, then Save.

Expected Results:
The iPhone which is monitoring for entry notifications should present a notification to the user that it has seen the iBeacon being broadcast from the second iPhone.

Actual Results:
No notification is presented.

Version:
iOS 8.1 (12B411)

Notes:
Some additional info:
 
Our app is written in Swift and was built with Xcode v6.0.1.
 
Since the bug manifested itself after the 8.1 update I've installed Xcode 6.1, updated the code to match the recent Swift changes (lots of new ! and fewer ?).
 
Running the newly rebuilt app in the debugger confirms that didEnterRegion & didExitRegion are only being called when the app is in the foreground with the device unlocked.
 
I've scanned the 8.1 release notes as well as the dev library and couldn't find any changes between 8 & 8.1 regarding background monitoring of iBeacon regions. Have I overlooked something or can we look forward to iOS 8.1.1 fixing this?

Configuration:
iPhone 6 Plus 128GB, au/kddi

Comments

Also filed as 19250640

We're seeing the same problem with location-based regions (not ibeacon ones) still in 8.1.3. Seems to be reasonably reproducible. In my case, toggling the location permission in settings didn't immediately fix the problem but did after a reboot. Also deleting and reinstalling the app (which reprompts for location permission) fixed the problem immediately.

Update:

The iPhone we're using to test our app with iOS 8.1 has always had the privacy->location services->always set for the app (and the AirLocate example app) since the 8.0 betas. Today on a lark I toggled that to never and then back to always, and now background notifications are being received.

I have run through the tests and can confirm that iOS 8.1 is now calling locationManager:didEnterRegion: properly in all app run states. Somehow the OTA update caused the system to act as if privacy->location services was set to "While Using the App" even though it was set to "Always". Toggling between "Never" and "Always" causes iOS to behave properly.

I suggested that Apple look into what the 8.1 OTA update does to step on these user settings.


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!