User Consent
Important note:The TomTom Digital Cockpit SDK is not available for general use. Please contact us for more information.
For some online services to work, the user must agree to share their personal data. For example, to be able to see traffic on the map, the user has to agree to share their location, by giving consent.
In TomTom Digital Cockpit (TTDC) there are a number of consent types. This allows for giving the end-user granular control over which data is shared. The consent types are:
ANALYTICS
- For data analytics events to be logged and collected by TomTom's back-end.CONNECTED_SERVICES
- For online navigation services and features, such as for search and routing. Note: onboard services still work without consent, as no personal data is shared.LOCATION
- For sharing the current location. For example, this consent is required to get traffic services.
To set the end user's consent in the TTDC platform, the following interface need to be
implemented: PrivacySettingsService
.
For more details on how to create an IVI service, see the Create an IVI Service page.
Setting User Consent, code example
For legal reasons, the User Consent UI cannot be implemented in the TTDC platform itself, but must instead be implemented by the customer for their end users.
The following example is using the template app, from the examples source, to add user consent.
ConfigureConsentPrivacySettingsService.kt:
Implement the PrivacySettingsService interface.
1package com.example.ivi.template.app.privacysettings23import com.tomtom.ivi.platform.framework.api.common.annotations.IviExperimental4import com.tomtom.ivi.platform.framework.api.ipc.iviservice.IviServiceHostContext5import com.tomtom.ivi.platform.navigation.api.service.privacysettings.PrivacySettingsService6import com.tomtom.ivi.platform.navigation.api.service.privacysettings.PrivacySettingsServiceBase78/**9 * Implementation for the [PrivacySettingsService]. This service is implemented to10 * provide consent for data collection.11 */12@OptIn(IviExperimental::class)13internal class ConfigureConsentPrivacySettingsService(iviServiceHostContext: IviServiceHostContext):14 PrivacySettingsServiceBase(iviServiceHostContext) {1516 override fun onCreate() {17 super.onCreate()18 /*19 * Ask the end-user if they agree to share their personal data here. Then set the20 * relevant consentTypes.21 *22 * NOTE: This example enables consent for everything, without asking the user!23 */24 consentTypes = setOf(25 PrivacySettingsService.ConsentType.ANALYTICS,26 PrivacySettingsService.ConsentType.CONNECTED_SERVICES,27 PrivacySettingsService.ConsentType.LOCATION28 )29 serviceReady = true30 }3132 companion object33}
ConfigureConsentPrivacySettingsServiceHostBuilder.kt:
Implement a host builder for the service.
1package com.example.ivi.template.app.privacysettings23import com.tomtom.ivi.platform.framework.api.ipc.iviservice.AnyIviServiceBase4import com.tomtom.ivi.platform.framework.api.ipc.iviservice.IviServiceHostContext5import com.tomtom.ivi.platform.framework.api.ipc.iviservice.SimpleIviServiceHostBuilder67public class ConfigureConsentPrivacySettingsServiceHostBuilder : SimpleIviServiceHostBuilder() {89 public override fun createIviServices(iviServiceHostContext: IviServiceHostContext):10 Collection<AnyIviServiceBase> =11 listOf(ConfigureConsentPrivacySettingsService(iviServiceHostContext))1213 public companion object14}
build.gradle.kts:
Finally, replace the stock service with your own implementation.
1import com.tomtom.ivi.platform.gradle.api.common.annotations.EXPERIMENTAL_API_USAGE2import com.tomtom.ivi.platform.gradle.api.common.dependencies.IviPlatformModuleReference3import com.tomtom.ivi.platform.gradle.api.common.dependencies.ModuleReference4import com.tomtom.ivi.platform.gradle.api.common.iviapplication.config.IviServiceHostConfig5import com.tomtom.ivi.platform.gradle.api.common.iviapplication.config.IviServiceInterfaceConfig6import com.tomtom.ivi.platform.gradle.api.defaults.config.privacySettingsServiceHost78public val configurePrivacySettingsServiceHost: IviServiceHostConfig =9 IviServiceHostConfig(10 serviceHostBuilderName = "ConfigureConsentPrivacySettingsServiceHostBuilder",11 ModuleReference(12 groupName = "com.example.ivi",13 moduleName = "template_app",14 packageName = "com.example.ivi.template.app.privacysettings"15 ),16 interfaces = listOf(17 IviServiceInterfaceConfig(18 serviceName = "PrivacySettingsService",19 serviceApiModule = IviPlatformModuleReference(20 "platform_navigation_api_service_privacysettings"21 )22 )23 )24 )2526// Remove the Stock version and add your own service host instead.27import com.tomtom.ivi.platform.gradle.api.defaults.config.privacySettingsServiceHost2829ivi {30 // ...31 application {32 // ...33 services {34 @Suppress(EXPERIMENTAL_API_USAGE)35 removeHost(privacySettingsServiceHost)36 addHost(configurePrivacySettingsServiceHost)37 }3839 // ...