MacKuba

Kuba Suder's blog on Mac & iOS development

What's New in Core Location

Categories: WWDC 19 0 comments Watch the video

Instead of giving the user the option of Always / When in Use / Don’t Allow, current options are:

  • Allow While in Use
  • *Allow Once* – a temporary authorization
  • Don’t Allow

In order to get Always access:

  • you call requestAlwaysAuthorization() as before
  • if the user grants access “While in Use”, your app gets “provisional always authorization
  • your delegate gets back a response that "Always" access was granted
  • then your app tries to actually use location in the background
  • some location event is generated, and only then iOS asks the user (at an appropriate moment) if they want to give the app "Always" access location in the background

You can only try this once, and if the user says they’d prefer to stay at the “While in Use” access level, they will not be asked again

You can also ask for “While in Use” first and then upgrade to “Always” later after the user uses the app for some time

Instead of diving APIs into those requiring “Always” and those that don’t, now the rule is: if your app accesses location while the app is in the foreground (or has started to do so in the foreground + shows a blue bar after going to the background), then it does not require “Always” access, regardless of which API it uses

On Apple Watch: being in an active complication counts as being in use

Temporary authorization (“Allow Once”): your app gets “While in Use” access, but it reverts back to .notDetermined when the app stops being used

Updates to Beacon Ranging API:

CLBeaconIdentityConstraint