Documentation Index

Fetch the complete documentation index at: https://usercentrics.document360.io/llms.txt

Use this file to discover all available pages before exploring further.

Import the App SDK

Prev Next

Flowchart illustrating steps for Usercentrics SDK implementation and consent management process.

The first step on the technical implementation side is to import the necessary SDK module(s) into your project.

Before you begin, it’s important to learn the following detail about the App SDK architecture: it includes the following two components:

  • UsercentricsCore: Contains all core functionality to collect, document and manage consent. If you want to build your own banner UI, that’s the only module you need.

  • UsercentricsUI: This component builds on the top of UsercentricsCore to provide a pre-built consent banner solution. Use it for a quick but still customizable solution. If you want to use this component, you must import UsercentricsCore as well.

Here is how to import the necessary modules:

iOS

Prerequisite

iOS 11 or higher

CocoaPods

  1. Install CocoaPods and follow the CocoaPods documentation to set up your project.

  2. On your Podfile, add the following line to include both UsercentricsCore and UsercentricsUI:

    platform :ios, '11.0'
    use_frameworks!  
    pod 'UsercentricsUI'


    Alternatively, add the following to include only UsercentricsCore:

    platform :ios, '11.0'
    use_frameworks!  
    pod 'Usercentrics'
  3. On the root directory of your project, run the following command to install the pod:

    pod install
  4. Open your .xcworkspace file.

🚀 You are now ready to start integrating Usercentrics.

Swift Package Manager (SPM)

From Xcode 11 and above, you can use Swift Package Manager to install the SDK.

  1. On Xcode, select File - Swift Packages - Add Package Dependency.

  2. Enter the package repository URLs.

    1. For Usercentrics UI: https://bitbucket.org/usercentricscode/usercentrics-spm-ui

    2. For UsercentricsCore: https://bitbucket.org/usercentricscode/usercentrics-spm-sdk

  3. Select the version you would like to use. We recommend sticking to "Up to Next Major" with the latest release as minor version.

🚀 You are now ready to start integrating Usercentrics.

Manually

Download and unzip the latest version of our SDKs:

  1. UsercentricsCore

  2. UsercentricsUI. Download the zip file containing 'Manual-Linking' in its name.

  3. Drag and drop .xcframework files to your Xcode project.

🚀 You are now ready to start integrating Usercentrics.

Android

Prerequisite

Android 5.0 (API 21) and higher

Android minimum SDK version

Support for versions lower than Android 5.0 (API Level 20) is planned to be removed in releases starting from April/24

Gradle

  1. If not present, add Maven Central repository URL to your top-level build.gradle file:

    allprojects {
        repositories {
            mavenCentral()
        }
    }
  2. Add the dependency to your app's build.gradle to include both UsercentricsCore and Usercentrics UI:

    dependencies {
        implementation "com.usercentrics.sdk:usercentrics-ui"
    }

    Alternatively, add the following to include only UsercentricsCore:

    dependencies {
        implementation "com.usercentrics.sdk:usercentrics"
    }

🚀 You are now ready to start integrating Usercentrics.

Manually

  1. Download and the latest version of our SDKs: Usercentrics Core and Usercentrics UI.

  2. Check the POM file is available in both links above. They may contain other libraries to be downloaded, download them if they are not present already in your environment.,

  3. If the dependencies are handled manually, move all .aar and .jar files to your project, if not, upload them to your Nexus solution.

🚀 You are now ready to start integrating Usercentrics.

Flutter

Prerequisites

  • Android 5.0 (API 21) or higher with Kotlin 1.7 or higher

  • iOS 11 or higher

  • Dart 2.12 or higher

  • Flutter 1.20 or higher

Android minimum SDK version

Support for versions lower than Android 5.0 (API Level 20) is planned to be removed in releases starting from April/24

Android with Kotlin version < 1.7

If you have an incompatible Kotlin version, you may see the following error when you run app on Android:

e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors

To solve this error, increase the version that is usually in the android/build.gradle file. Use a recent stable Kotlin version, for example: 1.5.31.

After this, proceed with the installation described in the Pub.dev section below.

Android version < 5.0 (API 21) and Usercentrics version < 2.13.0

If you support an Android version lower than 5.0 (API 21) and you don't have the multidex enabled in your project, you may see the following error when you run your app on Android:

D8: Cannot fit requested classes in a single dex file (# methods: 66055 > 65536)

You can change the minimum version of your application to 5.0 (API 21). That configuration is usually in the android/app/build.gradle file. Make sure that minSdkVersion is 21 or higher.

Although Android 5.0 version already supports 99% of all devices, if you still want to have support for Android 4.1 (API 16) you have to do the following:

  1. Add the multidex library to your application dependencies that is usually in the android/app/build.gradle file.

    implementation "androidx.multidex:multidex:2.0.1"

  2. Enable the option in the application build defaultConfig. It is usually in the same android/app/build.gradle file.

    multiDexEnabled true


  3. Make your application class initialize multidex. There are several options to do that, in Flutter the easiest way is to add it to the manifest. The manifest is usually located at android/app/src/main/AndroidManifest.xml.

    android:name="androidx.multidex.MultiDexApplication"


    After this, proceed with the installation described in the Pub.dev section below.

Android minimum SDK version

Support for versions lower than Android 5.0 (API Level 20) is planned to be removed in releases starting from April/24

iOS version < 11

If you have a iOS target version lower than 11 or you have no version at all (it defaults to version 9) you may see the following error when you run your app on iOS:

[!] Automatically assigning platform iOS with version 9.0 on target Runner because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform.

To solve this error, follow these steps:

  1. Define or increase the version of your Podfile at least to version 11. It is usually located at ios/Podfile.

    platform :ios, '11.0'


  2. Run flutter pub get again and open the iOS project using Xcode. It is usually located at ios/Runner.xcworkspace. Now, you have to select the Runner project and change the Deployment Target to the same version.

After this, proceed with the installation described in the Pub.dev section below.

Pub.dev

To install the SDK, add Usercentrics to your project via pub.dev:

flutter pub add usercentrics_sdk

🚀 You are now ready to start integrating Usercentrics.

React Native

Prerequisites

  • Android 5.0 (API 21) or higher with Kotlin 1.7 or higher

  • iOS 11 or higher

  • React Native 0.65 or higher

  • React 17.0 or higher

npm

To install the SDK, add Usercentrics to your project using npm:

npm i @usercentrics/react-native-sdk

🚀 You are now ready to start integrating Usercentrics.

Download the latest release of the Unity Package.

Static Linkage Support for iOS

Because we use ExternalDependencyManager, the project output when building for iOS, will be a CocoaPods workspace, which offers an option to Link frameworks statically. If you need support for Static Linkage on iOS, please download the latest package with the -static suffix. *e.g. Usercentrics-2.X.X-static.unitypackage.

Manual Linkage Support for iOS

In iOS, you have the flexibility to manually link frameworks when building your iOS applications, for instance, if you are using CMake for cross-platform development. If you need support for Manual Linkage, please download the latest version of the zip files:

  1. UsercentricsCore

  2. UsercentricsUI, containing the 'Manual-Linking' suffix. Please note if you need the -static version as well.

Installation on Unity IDE

Prerequisites

  • Android 5.0 (API 21), or higher, for the Minimum API Level and Android 12 (API 31) for the Target API Level

  • Java version 8 or 11 depending on the Unity Version

  • Kotlin 1.7 or higher

  • iOS 11 or higher

  1. Drag and drop Usercentrics.unitypackage into your Unity project. Alternatively, you can select the package from the menu Assets - Import Package - Custom Package.
    If you have already imported ExternalDependencyManager for Unity in your project, you can deselect it in the pop-up, to keep your previous configuration.
    Import package window

  2. Click Import.

  3. From Usercentrics/Prefabs, drag Usercentrics prefab into your scene. This will represent the game object for the banner.
    The name of this object needs to be Usercentrics.
    Drag & Drop

You are now ready to start integrating Usercentrics.

Troubleshooting

This section gives you some pointers on how to troubleshoot isses.

Unity Editor is NOT Supported

The Unity Editor is not supported. To test and debug the CMP you will need to run the project on a simulator or real device.

Troubleshooting an iOS setup

Cocoapods must be installed for iOS builds to work. Check their installation guide.

When opening the project built by Unity, you should always select the .xcworkspace file created by Cocoapods.

Troubleshooting an Android setup

Dependencies

When Android is selected as build platform, the dependency manager will ask you to download the dependencies that Usercentrics needs. We recommend enabling Android Auto-resolution to handle this. Make sure you have downloaded all Android Build Support Modules including OpenJDK.

Internet access

The Usercentrics SDK needs internet in order to initialize. Make sure you enable a required connection in your Android Player Settings.

You can do so under File - Build Settings - Android (selected) - Player Settings - Other Settings - Internet Access - Required.

ExternalDependencyManager and building

When using this plugin for the first time, a popup will appear asking if you want to enable Android Auto-resolution. We highly recommend to enable it, since it's natural for some Android libraries have conflicting dependencies. Auto-resolution can handle those conflicts for you.

Dependency conflicts (Duplicate classes) or ExternalDependencyManager fails to resolve dependencies

If the auto-resolution process fails to resolve any conflicts, modify your project's build configuration for Android. By doing so, you will not depend solely on the ExternalDependencyManager to download all dependencies. Instead, you allow Gradle to handle the resolution of dependencies and any emerging conflicts.

To do that, follow these steps:

  1. Go to File - Build Settings - Switch platform to Android,

  2. Go to Player Settings.

  3. Scroll to the last section Publishing Settings.

  4. Enable Custom Main Gradle Template.

  5. Enable Custom Gradle Properties File.

  6. Save & close.

  7. Go to Assets - External Dependency Manager - Android Resolver - Settings.

  8. Make sure Patch mainTemplate.gradle and  Patch gradleTemplate.properties are both enabled.