Skip to main content

Location tracking

The Mapbox Navigation SDK for iOS enables your application to observe and respond to the user's location. It helps you request permission to access a user's location, use a location provider to get location information for the device, and display the user's location on the map visually.

Privacy and permissions

Users must grant your application permission before it can access information about their location. During this permission prompt, a custom string may be presented explaining how the location will be used. This is specified by adding the key NSLocationWhenInUseUsageDescription to the Info.plist file with a value describing why the application requests these permissions.

Before iOS 14, the device could only send the user’s exact location. With iOS 14, users can opt into Approximate Location. Since users may toggle precise location off when initial permission for their location is requested by the app or in the System settings, we strongly encourage you to support Approximate Location.

Request temporary access to precise location

Certain application features may require precise location. The Mapbox Navigation SDK for iOS provides a wrapper of Apple’s Core Location APIs that requests temporary access to precise location when the user has opted out at the application settings level.

Make the following adjustments to your Info.plist file to provide explanations for system prompts that may appear during location prompts:

  • Provide users with a brief explanation of how the app will use their location data for temporary access:
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Your precise location is used to calculate turn-by-turn directions, show your location on the map, and help improve the map.</string>
  • Add LocationAccuracyAuthorizationDescription as an element of the NSLocationTemporaryUsageDescriptionDictionary dictionary to give users a brief explanation of why a feature in your app requires their exact location:
    <key>NSLocationTemporaryUsageDescriptionDictionary</key>
    <dict>
    <key>LocationAccuracyAuthorizationDescription</key>
    <string>Please enable precise location. Turn-by-turn directions only work when precise location data is available.</string>
    </dict>
Location tracking with the Maps SDK

Maps SDK is a dependency of the Navigation SDK, you have access to additional location tracking capabilities including a protocol for handling changes in location authorization, customizing accuracy authorization handling, and custom location providers. Read more in the Maps SDK's User location guide.

Was this page helpful?