Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

CoreLocation.requestTemporaryFullAccuracyAuthorization

Asks for temporary access.

Component Version macOS Windows Linux Server iOS SDK
CoreLocation 11.1 ✅ Yes ❌ No ❌ No ❌ No ✅ Yes
MBS( "CoreLocation.requestTemporaryFullAccuracyAuthorization"; purpose )   More

Parameters

Parameter Description Example
purpose The purpose text.

Result

Returns OK or error.

Description

Asks for temporary access.
If your app doesn't have permission to access accurate location (see accuracyAuthorization), you can use this method to request temporary access to accurate location. This access will expire automatically, but it won't expire while the user is still engaged with your app. So, for example, while your app is in the foreground your app will retain the temporary access it was granted. Similarly, if your app starts a Continuous Background Location session with the background location indicator enabled (see -showsBackgroundLocationIndicator), your access to accurate location will remain as long as the background location indicator remains enabled. This allows your app to provide session-oriented experiences which require accurate location (e.g. fitness or navigation), even if the user has decided not to grant your app persistent access to accurate location.

When CoreLocation prepares the prompt for display, it will look at the NSLocationTemporaryUsageDescriptionDictionary key in your Info.plist. The value should be a dictionary containing usage descriptions. The purposeKey you provide to this method must correspond to an entry in that dictionary. To retrieve a localized string, CoreLocation will load your InfoPlist.strings file and try to look up a string using the purposeKey you provided. If that fails, CoreLocation will use the content provided in your Info.plist. For example, suppose your Info.plist contains the following.

<key>NSLocationTemporaryUsageDescriptionDictionary</key>
<dict>
<key>ExampleUsageDescription</key>
<string>This app needs accurate location so it can verify that you're in a supported region.</string>
<key>AnotherUsageDescription</key>
<string>This app needs accurate location so it can show you relevant results.</string>
</dict>

In this case, you would be able to provide either "ExampleUsageDescription" or "AnotherUsageDescription" for the purposeKey argument. Passing any other string would result in the prompt not being displayed. To localize these usage descriptions, you would add entries for "ExampleUsageDescription" and "AnotherUsageDescription" to your InfoPlist.strings file.

CoreLocation may decide against showing the user a prompt. For example, if your app already has access to accurate location or it is currently in the background.

Due to the info plist changes, this may only work in iOS apps.
For iOS 14.0 and macOS 11.0 or newer.

Release notes

Blog Entries

This function checks for a license.

Created 16th February 2021, last changed 14th July 2022


CoreLocation.requestLocation - CoreLocation.requestWhenInUseAuthorization