Permissions & auth
Contents
Contact us to learn more about licensing the CoPilot Native Nav SDK.
Permissions
The CoPilot Native Nav SDK needs to continue to track a driver’s location even while a different application is visible or the device is locked.
To allow this, go to the Signing & Capabilities tab. This is located in the Navigator panel > Targets (Click ProjectName) > Signing & Capabilities. Under Background Modes, enable Location updates. (Alternatively, add the location value to the UIBackgroundModes array in the Info tab.) Certain features may require full-accuracy locations. The Trimble Maps SDK for iOS provides a wrapper of Apple’s Core Location APIs. It requests temporary access to full-accuracy locations even when the user has opted out.
Make the following adjustments to your Info.plist file to enable these prompts and provide explanations to appear within them, including a brief explanation of how the app will use location data for temporary access.
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your precise location is used to show your location on the map.</string>
<key>NSLocationTemporaryUsageDescriptionDictionary</key>
<dict>
<key>LocationAccuracyAuthorizationDescription</key>
<string>Please enable precise location to show your location on the map.</string>
</dict>
Authentication
In order to use the APIs and SDK, you will need to authenticate your API key first. If you do not have an API key, you can request one. Authentication must be done prior to attempting to render a MapView or using the APIs. An example can be found below:
// Authorize the api key for the session.
// apiKey requires your Trimble Maps API key
init() {
let account = Account(apiKey: "Your-API-key-here", region: Region.worldwide)
AccountManager.default.account = account
AccountManager.default.delegate = AccountDelegate()
}
class AccountDelegate: AccountManagerDelegate {
func stateChanged(newStatus: AccountManagerState) {
if newStatus == .loaded {
// Account has initialized successfully, the SDK can now be used
}
}
}
When integrating with our services, it is important to account for potential licensing failures that may occur due to various reasons. To ensure reliable operation and avoid unnecessary API calls that may fail due to licensing issues, we recommend implementing a safety check in your integration.
if AccountManager.default.isLicensed(licensedFeature: .navigationSdk) {
if newStatus == .loaded {
// Account has initialized successfully, the SDK can now be used
}
} else {
// Handle the case where the account is not licensed for CoPilot Native Nav SDK
print("Account is not licensed for CoPilot Native Nav SDK")
}