.jpg)
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
Install CocoaPods and follow the CocoaPods documentation to set up your project.
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'On the root directory of your project, run the following command to install the pod:
pod installOpen 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.
On Xcode, select File - Swift Packages - Add Package Dependency.
Enter the package repository URLs.
For Usercentrics UI: https://bitbucket.org/usercentricscode/usercentrics-spm-ui
For UsercentricsCore: https://bitbucket.org/usercentricscode/usercentrics-spm-sdk
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:
UsercentricsUI. Download the zip file containing 'Manual-Linking' in its name.
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
If not present, add Maven Central repository URL to your top-level build.gradle file:
allprojects { repositories { mavenCentral() } }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
Download and the latest version of our SDKs: Usercentrics Core and Usercentrics UI.
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.,
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..png)
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.
.png)
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:
Add the multidex library to your application dependencies that is usually in the
android/app/build.gradlefile.implementation "androidx.multidex:multidex:2.0.1".png)
Enable the option in the application build
defaultConfig. It is usually in the sameandroid/app/build.gradlefile.multiDexEnabled true.png)
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".png)
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:
Define or increase the version of your Podfile at least to version 11. It is usually located at
ios/Podfile.platform :ios, '11.0'.png)
Run
flutter pub getagain and open the iOS project using Xcode. It is usually located atios/Runner.xcworkspace. Now, you have to select theRunnerproject and change theDeployment Targetto the same version..png)
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
-staticsuffix. *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:
UsercentricsUI, containing the 'Manual-Linking' suffix. Please note if you need the
-staticversion 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
Drag and drop
Usercentrics.unitypackageinto 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.
Click Import.
From
Usercentrics/Prefabs, dragUsercentricsprefab into your scene. This will represent the game object for the banner.
The name of this object needs to beUsercentrics.
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.
.png)
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:
Go to File - Build Settings - Switch platform to Android,
Go to Player Settings.
Scroll to the last section Publishing Settings.
Enable Custom Main Gradle Template.
Enable Custom Gradle Properties File.
Save & close.
Go to Assets - External Dependency Manager - Android Resolver - Settings.
Make sure Patch mainTemplate.gradle and Patch gradleTemplate.properties are both enabled.