Info
Content

[Unity] 1. consentmanager SDK Integration

Features

  • Supports both iOS and Android platforms.
  • Provides a bridge between Unity and native platform-specific CMP functionalities.
  • Allows you to initialize, manage user consent, and handle privacy-related data.

Getting Started

  1. Installation:
    • Download the latest release of the plugin.
    • Import the package into your Unity project using Assets > Import Package > Custom Package.

Usage:

Follow these steps to start using the plugin.

Initialization: To use the CMP functionality, initialize the CMPManager instance.

CmpManager.Instance.Initialize(domain, codeId, appName, language);
                
CmpManager.Instance.OpenConsentLayer();
                

Check Consent: Check if the user has given consent:

bool hasConsent = CmpManager.Instance.HasConsent();
                

Callbacks: Set callback listeners for various events:

CmpManager.Instance.AddEventListeners(OnOpen, OnClose, OnNotOpened, OnCmpButtonClicked, OnError);

Purpose and Vendor Checks: Check for consent related to specific purposes and vendors:

bool hasPurpose = CmpManager.Instance.HasPurpose(id);
bool hasVendor = CmpManager.Instance.HasVendor(id);
                

Export Data: Export CMP data:

string cmpString = CmpManager.Instance.ExportCmpString();

 

The Config JSON

In the CmpSdkConfig.json you can set the native SDK Version for iOS and Android which will be used for the build process: 

Find the compatible native SDK Versions here

{
  "displayName": "Consentmanager SDK",
  "name": "CmpSdk",
  "androidBasePath": "net.consentmanager.sdk",
  "version": "1.0.0",
  "androidLibraryVersion": "x.xx.x",
  "iosLibraryVersion": "x.xx.x",
  "description": "Unity plugin helps you to use native Consentmanager functionality on Android and iOS."
}

Build Settings

To change the build settings go to Window -> CmpSdk 

pluginwindow-unity.png

iOS Build Settings
  • Enable iOS Build Script: Toggle this to enable or disable the build script responsible for integrating the iOS SDK into the Unity project.
  • xcFramework Path: Specify the path to the xcFramework directory. This path can be edited directly or browsed to using the accompanying button.
  • Include Version Tag: When enabled, appends the iOS SDK version to the xcFramework path, allowing for version-specific configurations.
  • Resulting Framework Path: Displays the fully resolved path to the xcFramework, including the SDK version if the version tag is included.
  • Enable App Tracking Transparency: Toggle this to enable the App Tracking Transparency feature for iOS, which is necessary for user consent under iOS privacy guidelines.
  • App Tracking Transparency Consent Message: A text field to input the custom message displayed to users when requesting consent for tracking. This message should be clear and concise, explaining why the consent is needed.
Android Build Settings
  • Enable Android Build Script: Toggle to enable or disable the build script for integrating the Android SDK into the Unity project. 
  • Integrate Custom Layout: When enabled, this allows the use of a custom layout for the consent layer. Disabling this will present the consent layer in full screen by default. If your project doesn't utilize a custom layout and you prefer to disable this option. 

Roadmap for future features:

  • disableVendorList, enableVendorList
  • disablePurposeList, enablePurposeList
  • Cmp ATT Manager for iOS

Compatibility

  • Unity 20XX.X.X or later
  • iOS (via DllImport)
  • Android (via JNI)

Support

For bug reports, feature requests, or general inquiries, please open an issue on the repository.

License

This plugin is licensed under the MIT License.

Credits

Created and maintained by Skander Ben Abdelmalak.

Back to top