What’s new in CoreLocation for iOS 14

Ryan NHP
Level Up Coding
Published in
2 min readJun 25, 2020

--

New accuracy authorization in iOS 14

In WWDC 20, Apple introduced new location privacy authorization for iOS users is CLAccuracyAuthorization which includes: fullAccuracy and reducedAccuracy. What are they?

fullAccuracy: Receive accurate location information.

reducedAccuracy: Location estimates will have a horizontalAccuracy on the order of about 5km. Applications should be prepared to receive locations that are up to 20 minutes old.

How’s it looks like in iOS 14?

Where to get this status in code?

If you set a delegate for your locationManager, you can get the status in this function (from iOS 14)

func locationManagerDidChangeAuthorization(_ manager: CLLocationManager)

The function above is the replacement for this function (which works for all iOS below 14)

func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)

Here is sample code that handles which accuracy authorization is selected by users

There’s a key NSLocationDefaultAccuracyReduced (Bool) to allow you to set the default accuracy reduced or not whenever you request location authorization. Set this key in Info.plist

What if you set NSLocationDefaultAccuracyReduced to true or false?

False: Can toggle to choose .fullAccuracy or .reducedAccuracy

True: Default is .reducedAccuracy

When users select Precise is Off but you want to ask them for the accurate location, Apple also support us with 2 new functions in iOS 14 are:

What is purposeKey here?

purposeKey is a key that let the app know to get an explanation for each situation that you set in Info.plist

For example, if you set in Info.plist file with these keys and values

When you request temporary full accuracy authorization with purposeKey: “ForDelivery”

you will get a popup like this

These 2 functions only execute if accuracyAuthorization is .reducedAccuracy

--

--