Quickstart
The TomTomSDKLocationProvider
module provides an interface for obtaining and working with location updates. It provides implementations for getting an actual user location with and without Apple Services, as well as one for simulating locations.
To use the Location module, you need to configure the project and add the dependencies.
Project setup
To use the TomTomSDKLocationProvider
module, you will need to configure the project according to the project setup guide and import the necessary frameworks using the following instructions, based on your preferred package manager:
Swift Package Manager
- Open your App’s target and navigate to General > Frameworks, Libraries, and Embedded Content.
- Add the following TomTomSDK libraries from the provided code snippet. Once the project is set up, import the mentioned frameworks into your code.
import TomTomSDKLocationProvider
CocoaPods
- Add the
TomTomSDKLocationProvider
module to your project’sPodfile
:1TOMTOM_SDK_VERSION = '0.67.0'23target 'YourAppTarget' do4 use_frameworks!5 pod 'TomTomSDKLocationProvider', TOMTOM_SDK_VERSION6end - Install the dependencies by executing the following commands in the project directory:
pod repo-art update tomtom-sdk-cocoapodspod install --repo-update
- Once the project is set up, import the following framework:
import TomTomSDKLocationProvider
Existing location providers
The TomTomSDKLocationProvider
module provides the basic LocationProvider
protocol. All location engines have to adopt this protocol. The TomTomSDKLocationProvider
module contains the following location engine implementations:
DefaultCLLocationProvider
- relies on the AppleCore Location
services.SimulatedLocationProvider
- simulates updates for testing purposes and previewing routes.
Learn more about existing location providers in the Built-in location providers.
Custom location providers
Within the TomTom SDKs, developers are not limited to the provided location providers and can use their own services to record locations, or develop their own custom simulated location updates. Read more about creating your own custom location provider in the Create your own provider guide.
Location validator
LocationValidator
defines the interface for checking if the location is fixed or not. The GPS fix status indicates the quality of the signal, or the accuracy and reliability of the location being reported. The TomTomSDKLocationProvider
module provides the DefaultLocationValidator
or developers can create the custom one.
Location permissions
If the application is going to use user location data, you have to request the correct permissions. In particular, the user must grant location permission before the location provider can be used. Complete instructions to request location permissions on iOS can be found at Requesting authorization for location services.