{"id":28186813,"url":"https://github.com/axeptio/sample-app-android","last_synced_at":"2026-03-17T19:29:37.530Z","repository":{"id":230075775,"uuid":"766934498","full_name":"axeptio/sample-app-android","owner":"axeptio","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-29T10:24:36.000Z","size":12665,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-08-29T11:23:38.445Z","etag":null,"topics":["android","cmp","mobile","sample","sdk"],"latest_commit_sha":null,"homepage":"https://www.axept.io/","language":"Kotlin","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axeptio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-03-04T12:05:24.000Z","updated_at":"2025-08-29T10:24:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"1095d8bd-470a-4c8c-9e0e-627e6cb6e2f4","html_url":"https://github.com/axeptio/sample-app-android","commit_stats":null,"previous_names":["axeptio/sample-app-android"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/axeptio/sample-app-android","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axeptio%2Fsample-app-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axeptio%2Fsample-app-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axeptio%2Fsample-app-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axeptio%2Fsample-app-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axeptio","download_url":"https://codeload.github.com/axeptio/sample-app-android/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axeptio%2Fsample-app-android/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273816622,"owners_count":25173465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","cmp","mobile","sample","sdk"],"created_at":"2025-05-16T07:10:57.828Z","updated_at":"2026-03-17T19:29:32.500Z","avatar_url":"https://github.com/axeptio.png","language":"Kotlin","readme":"\u003cimg src=\"https://github.com/user-attachments/assets/c4c2d3a6-52a1-4515-b27f-4041af19fcf6\" width=\"600\" height=\"300\"/\u003e\n\n# Axeptio Android SDK Documentation\n\n\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/axeptio/sample-app-android/pulls)  [![Axeptio SDK Version](https://img.shields.io/github/v/release/axeptio/axeptio-android-sdk)](https://github.com/axeptio/axeptio-android-sdk/releases) [![Java Integration](https://img.shields.io/badge/Integration-Java%20%26%20XML-blue)](https://github.com/axeptio/sample-app-android/tree/main/samplejava) [![Kotlin Integration](https://img.shields.io/badge/Integration-Kotlin%20%26%20Compose-blue)](https://github.com/axeptio/sample-app-android/tree/main/samplekotlin) [![Android SDK Compatibility](https://img.shields.io/badge/Android%20SDK-%3E%3D%2026-blue)](https://developer.android.com/studio)\n \n\n\n\n\n\nWelcome to the Axeptio Mobile SDK Samples project! This repository demonstrates how to implement the **Axeptio Android SDK** in your mobile applications.\n## Table of Contents\n1. [Overview](#overview)\n2. [Getting Started](#getting-started)\n3. [Local Testing with Production Widget Configuration](#local-testing-with-production-widget-configuration)\n4. [Switching Between Publisher and Brand Flavors](#switching-between-publisher-and-brand-flavors)\n5. [Axeptio SDK Implementation](#axeptio-sdk-implementation)\n6. [Initialize the SDK](#initialize-the-sdk)\n7. [Responsibilities: Mobile App vs SDK](#responsibilities-mobile-app-vs-sdk)\n8. [Get Stored Consents](#get-stored-consents)\n9. [Show Consent Popup on Demand](#show-consent-popup-on-demand)\n10. [Popup Events](#popup-events)\n11. [Event source for KPI tracking](#event-source-for-kpi-tracking)\n12. [Sharing Consents with Other Web Views](#sharing-consents-with-other-web-views)\n13. [Clear User's Consent Choices](#clear-users-consent-choices)\n14. [Google Consent v2](#google-consent-v2)\n15. [TCF Vendor Management APIs](#tcf-vendor-management-apis)\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n## Overview\nThis project includes two modules:\n- `samplejava`: Demonstrates how to use the Axeptio SDK with Java and XML.\n- `samplekotlin`: Shows the integration of the Axeptio SDK with Kotlin and Compose, including advanced debugging features and configuration management.\n\nBoth modules can be built using either the **brands** or **publishers** variants, depending on your specific needs.\n\n### Sample App Features\nThe `samplekotlin` module includes additional debugging and testing capabilities:\n- **Configuration Management**: Dynamic switching between Brands and Publishers TCF services\n- **Debug Consent Info**: Detailed analysis of TCF consent data and vendor information  \n- **Vendor Consent Testing**: Live testing interface for individual vendor consent validation\n- **Automation Scripts**: Complete build, deploy, and testing automation\n\n\u003e **⚠️ Note**: The `ConfigurationManager` class is part of the sample application and is not included in the Axeptio SDK. It demonstrates how to implement dynamic configuration switching in your own applications.\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n## Getting Started\nTo begin testing the Axeptio SDK sample applications, follow these steps:\n\n##### Clone the repository\n\nFirst, clone the repository to your local development environment:\n```bash\ngit clone https://github.com/axeptio/sample-app-android\n```\n##### Configure your Github access token\n\u003e 🛡️ Maven requires authentication to access private repositories such as GitHub Packages.\n\u003e Without valid credentials (GitHub username and token), Gradle will not be able to download dependencies and will return a 401 Unauthorized error.\n\u003e The following steps explain how to create a Personal Access Token and configure Gradle to use it securely via environment variables.\n\nTo properly configure access to the Axeptio SDK, you need to add your GitHub token in the `settings.gradle.kts` file to fetch the SDK from the private repository. The library is not available on a public Maven repository, so it is crucial to configure the private repository correctly to avoid errors. You can also consider publishing the Axeptio SDK to a public repository to simplify integration, reducing the process complexity. Here’s how to configure the private repository in the `settings.gradle.kts` file:\n```kotlin\nmaven {\n    url = uri(\"https://maven.pkg.github.com/axeptio/axeptio-android-sdk\")\n    credentials {\n        username = \"[GITHUB_USERNAME]\"  // Enter your GitHub username\n        password = \"[GITHUB_TOKEN]\"    // Enter your GitHub token\n    }\n}\n```\n\nYou can avoid hardcoding credentials by using environment variables instead of directly writing your GitHub username and token in the file. This is more secure and avoids leaking sensitive information.\nTo do this, replace the static strings with calls to environment variables using `System.getenv()` as follows:\n```kotlin\ncredentials {\n    username = System.getenv(\"GITHUB_USERNAME\")\n    password = System.getenv(\"GITHUB_TOKEN\")\n}\n```\nIf you haven't already created a GitHub Personal Access Token (PAT), you can do so by:\n1. Going [here](https://github.com/settings/tokens)\n2. Clicking on \"Generate new token (classic)\"\n3. Giving it a name and expiration\n4. Selecting the `read:packages` scope\n5. Generating and copying the token (you will not be able to see it again)\n\nOnce you have the token, export it as environment variables\n- On macOS/Linux (e.g., in `.bashrc`, `.zshrc`, or shell session):\n  ```bash\n  export GITHUB_USERNAME=\"your-github-username\"\n  export GITHUB_TOKEN=\"your-personal-access-token\"\n  ```\n- On Windows (CMD):\n  ```cmd\n  setx GITHUB_USERNAME \"your-github-username\"\n  setx GITHUB_TOKEN \"your-personal-access-token\"\n  ```\nAfter doing this, Gradle will automatically pick them up when resolving dependencies.\n\n##### Configure Fake Google App information\n\nFor local testing without real Google services\n\n```bash\nexport GOOGLE_PROJECT=\"demo-project-12345\"\nexport GOOGLE_API_KEY=\"AIzaSyDemoKey1234567890abcdefghijklmnop\"\n```\n\nand then run \n\n```bash\n./generate-config.sh\n```\n\n\n##### Ensure Proper Configuration in Axeptio Backoffice\nBefore proceeding with the integration, ensure that your project is correctly configured in the Axeptio backoffice. Specifically, verify that your clientId and configurationId are set up correctly. This is critical for the SDK to function as expected. If these values are not correctly configured, the SDK will not initialize properly, leading to errors during integration.\n\n##### Select the appropriate sample module\nChoose the module corresponding to your preferred programming language and UI framework:\n\n- **samplejava**: Java and XML integration\n- **samplekotlin**: Kotlin and Compose integration\n\n##### Choose your build variant:\nDepending on your use case, select the appropriate build variant:\n\n- **publishers**\n- **brands**\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n## Local Testing with Production Widget Configuration\nTo test SDK changes using a cookie configuration from the production backoffice, follow these steps:\n1. Checkout the `axeptio-android-sdk-sources` repository and switch to the branch you need to test.\n2. Configure the widget as described in the configuration section.\n\nTo test the version currently in production, instead checkout the `sample-app-android repository`, configure the widget, and in `build.gradle.kts` set the desired SDK version, for example: \n```gradle\nimplementation(\"io.axept.android:android-sdk:2.0.6\")\n```\nTo configure the widget, update the productFlavors in `build.gradle.kts` with the appropriate `AXEPTIO_CLIENT_ID`, `AXEPTIO_COOKIES_VERSION`, and `AXEPTIO_TARGET_SERVICE`. Example:\n```kotlin\nproductFlavors {\n    create(\"publishers\") {\n        dimension = \"service\"\n        buildConfigField(\"String\", \"AXEPTIO_CLIENT_ID\", \"\\\"67b63ac7d81d22bf09c09e52\\\"\")\n        buildConfigField(\"String\", \"AXEPTIO_COOKIES_VERSION\", \"\\\"tcf-consent-mode\\\"\")\n        buildConfigField(\"String\", \"AXEPTIO_TARGET_SERVICE\", \"\\\"publishers\\\"\")\n    }\n    create(\"brands\") {\n        dimension = \"service\"\n        buildConfigField(\"String\", \"AXEPTIO_CLIENT_ID\", \"\\\"67f3f816b336596c4a7c741c\\\"\")\n        buildConfigField(\"String\", \"AXEPTIO_COOKIES_VERSION\", \"\\\"demo-en-EU\\\"\")\n        buildConfigField(\"String\", \"AXEPTIO_TARGET_SERVICE\", \"\\\"brands\\\"\")\n    }\n}\n```\nUse the *Build Variants* tab to switch between brands and publishers as needed. Finally, make sure your `settings.gradle.kts` includes your GitHub credentials for accessing the SDK:\n```kotlin\nmaven {\n    url = uri(\"https://maven.pkg.github.com/axeptio/axeptio-android-sdk\")\n    credentials {\n        username = \"USER\" // TODO: GITHUB USERNAME\n        password = \"TOKEN\" // TODO: GITHUB TOKEN\n    }\n}\n```\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n## Switching Between Publisher and Brand Flavors\nThe Axeptio SDK provides two build flavors: `publishers` and `brands`. You can switch between them depending on your project needs. Each flavor activates specific behavior in the SDK.\n#### In Android Studio:\n1. Locate the *\"Build Variants\"* tab (usually in the lower-left corner of the IDE).\n2. If it's not visible, go to *View \u003e Tool Windows \u003e Build Variants* to enable it.\n3. In the Module column, select either `publishersDebug` or `brandsDebug` from the dropdown.\n\nUse Gradle commands to build a specific variant:\n```gradle\n./gradlew assemblePublishersDebug\n```\nor\n```gradle\n./gradlew assembleBrandsDebug\n```\nMake sure to clean the project if you switch flavors often:\n```bash\n./gradlew clean\n```\n\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n## Axeptio SDK Implementation\nThe Axeptio SDK provides consent management functionality for Android applications, enabling seamless integration for handling user consent.\n\n##### Gradle Implementation\nThe SDK is hosted on GitHub Packages and is compatible with Android SDK versions **\u003e= 26**.\n\nFollow these steps to integrate the Axeptio SDK into your Android project:\n- **Add the Maven repository to your `settings.gradle` file**\n\n   Ensure the provided GitHub token has the `read:packages` scope enabled. Add the following configuration to your `settings.gradle` file.\n - **Kotlin DSL**\n```kotlin\n// Start dependency resolution management block\ndependencyResolutionManagement {\n    repositories {\n        // Add Google's Maven repository to the project\n        google()\n        \n        // Add Maven Central repository\n        mavenCentral()\n        \n        // Add the GitHub Packages repository for the Axeptio SDK\n        maven {\n            // Set the URL of the GitHub repository hosting the Axeptio SDK\n            url = uri(\"https://maven.pkg.github.com/axeptio/axeptio-android-sdk\")\n            \n            // Configure credentials for accessing the GitHub Packages repository\n            credentials {\n                // Provide your GitHub username here\n                username = System.getenv(\"GITHUB_ACTOR\")\n                \n                // Provide your GitHub token here, ensuring the 'read:packages' scope is enabled\n                password = System.getenv(\"GITHUB_TOKEN\")\n            }\n        }\n    }\n}\n```\n - **Groovy**\n```groovy\nrepositories {\n    maven {\n        url = uri(\"https://maven.pkg.github.com/axeptio/axeptio-android-sdk\")\n        credentials {\n            username = \"[GITHUB_USERNAME]\"\n            password = \"[GITHUB_TOKEN]\"\n        }\n    }\n}\n```\n- **Add the SDK dependency to your `build.gradle` file**\nAfter adding the repository, include the Axeptio SDK as a dependency in your project.\n - **Kotlin DSL**\n```kotlin\ndependencies {  \n    implementation(\"io.axept.android:android-sdk:2.0.6\")\n}\n```\n - **Groovy**\n```groovy\ndependencies {\n    implementation 'io.axept.android:android-sdk:2.0.6'\n}\n```\nFor more detailed instructions, refer to the [GitHub Documentation](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry#using-a-published-package)\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n## Initialize the SDK\nTo initialize the Axeptio SDK, you must call the initialization method inside the `onCreate()` method of your main activity. This call should be made before invoking any other Axeptio SDK functions. The SDK can be configured for either **Publishers** or **Brands** using the `AxeptioService` enum during initialization.\n##### Kotlin Implementation\n```kotlin\noverride fun onCreate(savedInstanceState: Bundle?) {\n    super.onCreate(savedInstanceState)\n    \n    // Initialize the Axeptio SDK with the required configuration\n    AxeptioSDK.instance().initialize(\n        activity = this@MainActivity,  // Context of the current activity\n        targetService = AxeptioService.PUBLISHERS_TCF,  // Choose the target service: Publishers or Brands\n        clientId = \"your_client_id\",  // Replace with your actual client ID\n        cookiesVersion = \"your_cookies_version\",  // Specify the version of cookies management\n        token = \"optional_consent_token\"  // Optional: Provide an existing consent token if available\n    )\n}\n```\n##### Java Implementation\n```java\n@Override\nprotected void onCreate(@Nullable Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    \n    // Initialize the Axeptio SDK with the required configuration\n    Axeptio axeptio = AxeptioSDK.instance();\n    axeptio.initialize(\n        MainActivity.this,  // Context of the current activity\n        AxeptioService.PUBLISHERS_TCF,  // Choose the target service: Publishers or Brands\n        \"your_project_id\",  // Replace with your actual project ID\n        \"your_configuration_id\",  // Provide your configuration ID\n        \"optional_consent_token\"  // Optional: Provide an existing consent token if available\n    );\n}\n```\n##### Consent Popup Behavior\nOnce the SDK is initialized, the consent popup will automatically display if the user's consent is either expired or has not yet been registered. The SDK takes care of managing the consent state automatically.\n\n##### Transferring User Consents (Publishers)\nFor publishers, you can transfer a user's consent information by providing their Axeptio token. This token allows the SDK to automatically update the user's consent preferences in the SharedPreferences, following the TCFv2 (Transparency and Consent Framework) IAB (Interactive Advertising Bureau) specifications.\n\n\n##### Handling the \"INSTALL_FAILED_INVALID_APK\" Error\nThis error can occur during installation, typically due to issues with the APK or dependencies. The best solution is to perform a **clean build** to ensure that all libraries are properly integrated. To do so, execute the following command in your terminal:\n```bash\n./gradlew clean build\n```\nThis will clean the project and rebuild it, resolving any issues related to corrupted or improperly linked files. After completing the build, try reinstalling the app.\n\n###### Key Consideration \n- **Client ID** and **Configuration ID** should be properly configured according to your specific project setup.\n- The **Axeptio token** is optional, but it allows for better management of user consent states across different sessions.\n- Always ensure that you check for SDK initialization before calling `initialize()` to prevent multiple initializations that could cause crashes.\n\nThe integration of the Axeptio SDK into your mobile application involves clear delineation of responsibilities between the mobile app and the SDK itself. Below are the distinct roles for each in handling user consent and tracking.\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n## Responsibilities: Mobile App vs SDK\n#### **Mobile Application Responsibilities:**\n\n- **Event Handling and User Consent Updates:**\n   - The app is responsible for handling SDK events such as user consent actions. Based on these events, the app must adjust its behavior accordingly, ensuring that user consent is respected across sessions.\n\n#### **Axeptio SDK Responsibilities:**\n\n1. **Displaying the Consent Management Interface:**\n   - The Axeptio SDK is responsible for rendering the user interface for the consent management platform (CMP) once triggered. It provides a customizable interface for users to give or revoke consent.\n\n2. **Storing and Managing User Consent Choices:**\n   - The SDK securely stores and manages user consent choices, maintaining a persistent record that can be referenced throughout the app's lifecycle.\n\n3. **Sending Consent Status via APIs:**\n   - The SDK facilitates communication of the user's consent status through APIs, allowing the app to be updated with the user’s preferences.\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n## Get Stored Consents\nYou can retrieve the consents stored by the Axeptio SDK in **SharedPreferences**. The following example demonstrates how to access these values within your app:\n- **Kotlin Examples**\n```kotlin\n// Access SharedPreferences to retrieve stored consent values\nval sharedPref = context.getSharedPreferences(\"MyPrefs\", Context.MODE_PRIVATE)\n\n// Retrieve a specific consent value by key (replace \"key\" with the actual key you're using)\nval consentValue = sharedPref.getString(\"key\", \"default_value\")\n```\nIn this example, replace `key` with the actual key used to store consent information, and `default_value` with the value you want to return if no consent is found.\nFor more detailed information about the stored values, cookies, and how to handle them according to the Axeptio SDK, please refer to the [Axeptio Documentation](https://support.axeptio.eu/hc/en-gb/articles/8558526367249-Does-Axeptio-deposit-cookies)\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n## Show Consent Popup on Demand\nYou can trigger the consent popup to open on demand at any point in your application by using the following methods.\n\n- **Kotlin**:\n```kotlin\n// Show the consent popup on demand\nAxeptioSDK.instance().showConsentScreen(\n    activity = activity,  // Pass the activity context\n    managePreferencesUseCase = true  // Optional: Manages user preferences when the popup is shown\n)\n```\n- **Java**\n```java\n// Show the consent popup on demand\nAxeptioSDK.instance().showConsentScreen(\n    activity,  // Pass the activity context\n    true  // Optional: Manages user preferences when the popup is shown\n);\n```\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n## Popup Events\nWhen the consent popup is closed, an event is triggered. You can listen for this event by setting an `AxeptioEventListener`.\n- **Kotlin**:\n```kotlin\n// Set an event listener for when the consent popup is closed\nAxeptioSDK.instance().setEventListener(object : AxeptioEventListener {\n    override fun onPopupClosedEvent() {\n        // Handle the event when the popup is closed\n    }\n})\n```\n- **Java**\n```java\n// Set an event listener for when the consent popup is closed\nAxeptioSDK.instance().setEventListener(new AxeptioEventListener() {\n    @Override\n    public void onPopupClosedEvent() {\n        super.onPopupClosedEvent();\n        // Handle the event when the popup is closed\n    }\n});\n```\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n## Event source for KPI tracking\nTo ensure proper KPI attribution in the back office, the App SDK now adds a specific `event_source` value when emitting TCF events from the WebView.\n\n- `sdk-app-tcf` → Used when TCF is loaded in a mobile app (via WebView)\n- `sdk-web-tcf` → Used when TCF is loaded on a website\n- `sdk-app-brands` → Used when the brands widget is loaded in an app\n- `sdk-web` → Used for regular brands on the web\n\n\u003e ⚠️ This change ensures that events triggered from the App SDK are not incorrectly counted under Web KPIs.\n\nNo additional configuration is needed on your side if you are using the official SDK integration.\n\n\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n## Sharing Consents with Other Web Views\nThis feature is available exclusively for **Publishers** service.\n\nThe SDK provides a helper function to append the `axeptio_token` query parameter to any URL. You can either specify a custom user token or use the token currently stored in the SDK.\n- **Kotlin**:\n```kotlin\n// Append the Axeptio token to a URL\nAxeptioSDK.instance().appendAxeptioToken(\n    uri = Uri.parse(\"https://myurl.com\"),  // The URL to which you want to append the token\n    token = AxeptioSDK.instance().token ?: \"\"  // Use the current token, or provide a custom one\n)\n```\nThis will return: `https://myurl.com?axeptio_token=[token]`\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n## Clear User's Consent Choices\nTo clear the user’s consent choices, you can use the following method. Please note that this operation is asynchronous, so you should use the `AxeptioEventListener.onConsentCleared()` method to be notified when the user’s consent choices have been cleared from SharedPreferences.\n- **Kotlin**\n```kotlin\n// Clear the user's consent choices\nAxeptioSDK.instance().clearConsents()\n```\nYou can listen for the consent clearance event with the following code:\n```kotlin\n// Set an event listener for when the consents are cleared\nAxeptioSDK.instance().setEventListener(object : AxeptioEventListener {\n    override fun onConsentCleared() {\n        // Handle the event when consents are cleared\n    }\n})\n```\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n## Google Consent v2\nThis section describes how to integrate **Google Consent Mode** with the Axeptio SDK in your Android application.\n###### Prerequisites:\nBefore proceeding, ensure that **Firebase Analytics** is integrated into your Android project.\n###### How It Works:\nWhen user consent is collected through your **Consent Management Platform (CMP)**, the SDK will automatically set the `IABTCF_EnableAdvertiserConsentMode` key in the **SharedPreferences_** to `true`.\n##### Register to Google Consent Updates\nThe **Axeptio SDK** provides a callback method to listen for updates on Google Consent. These updates need to be mapped to the corresponding Firebase models. Once the consent statuses are mapped, you can update Firebase Analytics consent settings using the `setConsent()` method from **Firebase Analytics**.\n\n###### Kotlin Example:\n```kotlin\n// Set an event listener to listen for Google Consent Mode updates\nAxeptioSDK.instance().setEventListener(object : AxeptioEventListener {\n    override fun onGoogleConsentModeUpdate(consentMap: Map\u003cGoogleConsentType, GoogleConsentStatus\u003e) {\n        // Map the Google consent types and statuses to Firebase consent types\n        val firebaseConsentMap = consentMap.entries.associate { (type, status) -\u003e\n            val firebaseConsentType = when (type) {\n                GoogleConsentType.ANALYTICS_STORAGE -\u003e ConsentType.ANALYTICS_STORAGE\n                GoogleConsentType.AD_STORAGE -\u003e ConsentType.AD_STORAGE\n                GoogleConsentType.AD_USER_DATA -\u003e ConsentType.AD_USER_DATA\n                GoogleConsentType.AD_PERSONALIZATION -\u003e ConsentType.AD_PERSONALIZATION\n            }\n\n            val firebaseConsentStatus = when (status) {\n                GoogleConsentStatus.GRANTED -\u003e ConsentStatus.GRANTED\n                GoogleConsentStatus.DENIED -\u003e ConsentStatus.DENIED\n            }\n\n            firebaseConsentType to firebaseConsentStatus\n        }\n\n        // Update Firebase Analytics consent with the mapped consent statuses\n        Firebase.analytics.setConsent(firebaseConsentMap)\n    }\n})\n```\n\n###### Java Example:\n```java\n// Set an event listener to listen for Google Consent Mode updates\nAxeptioSDK.instance().setEventListener(new AxeptioEventListener() {\n    @Override\n    public void onGoogleConsentModeUpdate(@NonNull Map\u003cGoogleConsentType, ? extends GoogleConsentStatus\u003e consentMap) {\n        super.onGoogleConsentModeUpdate(consentMap);\n\n        // Prepare the Firebase consent map\n        Map\u003cFirebaseAnalytics.ConsentType, FirebaseAnalytics.ConsentStatus\u003e firebaseConsentMap = new HashMap\u003c\u003e();\n\n        // Map the Google consent types and statuses to Firebase consent types\n        for (Map.Entry\u003cGoogleConsentType, ? extends GoogleConsentStatus\u003e entry : consentMap.entrySet()) {\n            FirebaseAnalytics.ConsentType firebaseConsentType = null;\n            switch (entry.getKey()) {\n                case ANALYTICS_STORAGE:\n                    firebaseConsentType = FirebaseAnalytics.ConsentType.ANALYTICS_STORAGE;\n                    break;\n                case AD_STORAGE:\n                    firebaseConsentType = FirebaseAnalytics.ConsentType.AD_STORAGE;\n                    break;\n                case AD_USER_DATA:\n                    firebaseConsentType = FirebaseAnalytics.ConsentType.AD_USER_DATA;\n                    break;\n                case AD_PERSONALIZATION:\n                    firebaseConsentType = FirebaseAnalytics.ConsentType.AD_PERSONALIZATION;\n                    break;\n            }\n\n            FirebaseAnalytics.ConsentStatus firebaseConsentStatus = null;\n            switch ((GoogleConsentStatus) entry.getValue()) {\n                case GRANTED:\n                    firebaseConsentStatus = FirebaseAnalytics.ConsentStatus.GRANTED;\n                    break;\n                case DENIED:\n                    firebaseConsentStatus = FirebaseAnalytics.ConsentStatus.DENIED;\n                    break;\n            }\n\n            // Add the consent status mapping to the Firebase consent map\n            if (firebaseConsentType != null \u0026\u0026 firebaseConsentStatus != null) {\n                firebaseConsentMap.put(firebaseConsentType, firebaseConsentStatus);\n            }\n        }\n\n        // Update Firebase Analytics with the mapped consent statuses\n        FirebaseAnalytics.getInstance(MainActivity.this).setConsent(firebaseConsentMap);\n    }\n});\n```\n##### Summary of Steps:\n1. Integrate **Firebase Analytics** into your Android project.\n2. Use the provided listener `onGoogleConsentModeUpdate()` to capture consent updates.\n3. Map the **Google Consent Types** and **Google Consent Statuses** to **Firebase Consent Types-**.\n4. Use Firebase’s `setConsent()` method to update the user’s consent status in Firebase Analytics.\n\nBy following these steps, you can ensure that Google Consent Mode is correctly integrated with your application, and Firebase Analytics receives the consent status updates accordingly.\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n## TCF Vendor Management APIs\nThe Axeptio SDK provides comprehensive APIs for managing vendor consent in TCF (Transparency and Consent Framework) mode. These APIs are **exclusively available for Publishers using the TCF service** and allow you to query individual vendor consent states, implement vendor-specific functionality, and maintain compliance with IAB TCF requirements.\n\n#### When to Use TCF Vendor APIs\nUse these APIs when your app needs to:\n- Query consent status for specific advertising vendors\n- Implement vendor-specific data processing logic\n- Debug consent collection issues in TCF mode\n- Ensure compliance with specific vendor requirements\n\n### Available TCF Vendor APIs\nThese APIs allow you to retrieve and analyze vendor consent information in TCF mode:\n\n##### Get All Vendor Consents\nReturns a map of all vendor IDs with their consent status:\n- **Kotlin**:\n```kotlin\ntry {\n    val vendorConsents: Map\u003cInt, Boolean\u003e = AxeptioSDK.instance().getVendorConsents()\n    // vendorConsents contains: {755: true, 756: false, 757: true, ...}\n    \n    vendorConsents.forEach { (vendorId, isConsented) -\u003e\n        println(\"Vendor $vendorId: ${if (isConsented) \"CONSENTED\" else \"REFUSED\"}\")\n    }\n} catch (e: Exception) {\n    // Handle potential errors (e.g., SDK not initialized, no consent data)\n    Log.e(\"VendorConsents\", \"Error retrieving vendor consents: ${e.message}\")\n}\n```\n\n##### Get Consented Vendors List\nReturns only the vendor IDs that have been consented to:\n- **Kotlin**:\n```kotlin\ntry {\n    val consentedVendors: List\u003cInt\u003e = AxeptioSDK.instance().getConsentedVendors()\n    // consentedVendors contains: [755, 757, 760, ...]\n    \n    println(\"${consentedVendors.size} vendors have been consented to\")\n    consentedVendors.forEach { vendorId -\u003e\n        println(\"✅ Vendor $vendorId is consented\")\n    }\n} catch (e: Exception) {\n    Log.e(\"ConsentedVendors\", \"Error retrieving consented vendors: ${e.message}\")\n}\n```\n\n##### Get Refused Vendors List\nReturns only the vendor IDs that have been refused:\n- **Kotlin**:\n```kotlin\ntry {\n    val refusedVendors: List\u003cInt\u003e = AxeptioSDK.instance().getRefusedVendors()\n    // refusedVendors contains: [756, 758, 759, ...]\n    \n    println(\"${refusedVendors.size} vendors have been refused\")\n    refusedVendors.forEach { vendorId -\u003e\n        println(\"❌ Vendor $vendorId is refused\")\n    }\n} catch (e: Exception) {\n    Log.e(\"RefusedVendors\", \"Error retrieving refused vendors: ${e.message}\")\n}\n```\n\n##### Check Individual Vendor Consent\nCheck if a specific vendor has consent:\n- **Kotlin**:\n```kotlin\ntry {\n    val vendorId = 755 // Example vendor ID\n    val isConsented: Boolean = AxeptioSDK.instance().isVendorConsented(vendorId)\n    \n    if (isConsented) {\n        println(\"✅ Vendor $vendorId has consent - proceed with data processing\")\n        // Safe to process data with this vendor\n    } else {\n        println(\"❌ Vendor $vendorId does not have consent - skip data processing\")\n        // Do not process data with this vendor\n    }\n} catch (e: Exception) {\n    Log.e(\"VendorCheck\", \"Error checking vendor $vendorId: ${e.message}\")\n    // Assume no consent on error for safety\n}\n```\n\n### Debug and Analysis APIs\nFor debugging and detailed consent analysis:\n\n##### Get Consent Debug Information\nReturns detailed consent information including TCF strings and raw data:\n- **Kotlin**:\n```kotlin\ntry {\n    val debugInfo: Map\u003cString, Any?\u003e = AxeptioSDK.instance().getConsentDebugInfo()\n    \n    // Access common TCF fields\n    val tcfString = debugInfo[\"IABTCF_TCString\"] as? String\n    val vendorConsents = debugInfo[\"IABTCF_VendorConsents\"] as? String\n    val vendorLegitimateInterests = debugInfo[\"IABTCF_VendorLegitimateInterests\"] as? String\n    \n    println(\"TCF String: $tcfString\")\n    println(\"Vendor Consents Bitstring: $vendorConsents\")\n    println(\"Vendor Legitimate Interests: $vendorLegitimateInterests\")\n    \n    // Log all available debug fields\n    debugInfo.forEach { (key, value) -\u003e\n        println(\"$key: $value\")\n    }\n} catch (e: Exception) {\n    Log.e(\"DebugInfo\", \"Error retrieving debug information: ${e.message}\")\n}\n```\n\n### Best Practices for Vendor API Usage\n\n1. **Error Handling**: Always wrap API calls in try-catch blocks as these APIs may throw exceptions if the SDK is not properly initialized or if no consent data is available.\n\n2. **TCF Service Requirement**: These vendor APIs are **exclusively for Publishers using the TCF service**. When using the **Brands** service, these APIs will return empty results as vendor consent management is specific to the TCF framework.\n\n3. **Performance Considerations**: Cache vendor consent results when possible, as parsing TCF data can be computationally intensive for large vendor lists.\n\n4. **Data Processing Logic**: Use `isVendorConsented()` in your data processing pipeline to ensure compliance:\n```kotlin\nfun processUserData(vendorId: Int, userData: UserData) {\n    if (AxeptioSDK.instance().isVendorConsented(vendorId)) {\n        // Proceed with data processing\n        sendDataToVendor(vendorId, userData)\n    } else {\n        // Skip processing for this vendor\n        Log.d(\"Compliance\", \"Skipping vendor $vendorId - no consent\")\n    }\n}\n```\n\n5. **Initialization Check**: Ensure the SDK is initialized before calling these APIs by checking that you have called the `initialize()` method successfully before attempting to retrieve vendor consent data.\n\n\u003e **⚠️ Important Note**: The TCF vendor consent APIs are available starting from SDK version 2.0.8 and are **exclusively for Publishers using the TCF service**. These APIs will return empty results when used with the Brands service, as vendor consent management is specific to the TCF framework.\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\nFor more detailed information, you can visit the [Axeptio documentation](https://support.axeptio.eu/hc/en-gb).\nWe hope this guide helps you get started with the Axeptio Android SDK. Good luck with your integration, and thank you for choosing Axeptio!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxeptio%2Fsample-app-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxeptio%2Fsample-app-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxeptio%2Fsample-app-android/lists"}