iOS 14 - how to get iBeacon to wake up the app when precise location permission is denied?

2.4k views Asked by At

I’m running into the following problem with iOS 14.0 previously - with background location permission I could:

  • Register for iBeacon region monitoring
  • Kill the app from the app switcher
  • Tap the screen and see the app relaunched in the console.
  • App is running but is not in the app switcher

Retested with iOS14, without precise location my app is no longer being woken up from being terminated from the app switcher.

Re-enabled precise location permission and everything works as before.

What do I need to do to enable the background app to wake up for the iBeacon region without precise location permission?

Or

How do I detect that the precise location permission is missing and notify the user that the app will not work as expected?

ios14 precise permission missing

1

There are 1 answers

0
davidgyoung On

The Precise Location switch is new to iOS 14, and the specifics of what happens when user switch it to off are unfortunately not well documented by Apple. Here is a summary based on experimentation:

With Precise Location Enabled/Disabled:

                                      Precise Location
CoreLocation Accuracy/Function        Enabled Disabled
----------------------------------    -------- -------
kCLLocationAccuracyThreeKilometers      YES     YES
kCLLocationAccuracyReduced              YES     YES
kCLLocationAccuracyBest                 YES    DEGRADED
kCLLocationAccuracyNearestTenMeters     YES    DEGRADED
kCLLocationAccuracyHundredMeters        YES    DEGRADED
kCLLocationAccuracyKilometer            YES    DEGRADED
Beacon Monitoring                       YES      NO
Beacon Ranging                          YES      NO

                                      Precise Location
CoreBluetooth                         Enabled Disabled
----------------------------------    -------- -------
Bluetooth LE scanning                   YES       NO

                                      Precise Location
NearbyInteraction                     Enabled Disabled
----------------------------------    -------- -------
NI Ranging                              YES       NO

When precise location is disabled, lat/lon location updates to CoreLocation will be degraded to that provided by kCLAccuracyReduced similar to 3km accuracy provided by cell tower data.

Ranging and Monitoring of iBeacons is blocked -- delegate method callbacks do not get made, and apps will not be launched in the background. Nearby Interaction ranging is blocked.

These effects take effect immediately when you turn off Precise Location. You can see this yourself by looking at logging from your app while it is running, then going to settings to turn off Precise Location and seeing the behavioral changes.

Unfortunately, there is nothing you can do to force iOS to give you beacon or other location updates when the user has disabled Precise Location. The best you can do is detect that the user has done this (use code like below), and then prompt the user to change this in settings so your app works properly.

        if CLLocationManager.locationServicesEnabled() {
            if #available(iOS 14.0, *) {
                switch self.locationManager.accuracyAuthorization {
                    case .fullAccuracy:
                        NSLog("Precise Location allowed")
                    case .reducedAccuracy:
                        NSLog("Precise location disabled")
                    default:
                        NSLog("Precise Location not known")
                }
            }
        }