Unity Implementation

InMobi Choice is compatible with Unity version 2019.4.* and later.

CMP SDK & Configuration

Configure InMobi Choice for Your Mobile App

Before integrating InMobi Choice into your mobile app must be configured on the dashboard. Follow these steps:

  1. Log in to the Choice dashboard using your credentials.
  2. Click the Protect An App button.

Create New App

  1. Navigate to the Create a New App page.
  2. Provide essential details about your app, including its name, type, logo, and the consent you aim to acquire from users.
  3. After completion, click the Download SDK button.

Download InMobi Choice Unity Package

Click here to download the InMobi Choice Unity Package.

Import InMobi Choice Unity Package to Project

  1. Open Unity and navigate to the Assets >> Import Package >> Custom Package.
  2. Locate and select the downloaded InMobi Choice Unity Package file. You can view the contents of the package in Unity.
  3. Select all the entries and click Import.

Add Dependency Package

  1. In Unity Editor, navigate to Window >> Package Manager.
  2. Click the plus (+) icon on the top right corner of the Package Manager window.
  3. Select Add package from git URL and enter com.unity.nuget.newtonsoft-json.
  4. Click Add.

Find Your P-CODE

To initialize the SDK, you must provide your account's p-code for proper identification. After you log in to the Choice portal, you can see the p-code at the top right corner of the screen.

Start Choice

  1. In the designated method for initiating the choice process, invoke the StartChoice() method within the ChoiceCMP class. Ensure you provide the PCode obtained from the InMobi Choice portal as an argument.
    public void StartChoice() 
        ChoiceCMP.StartChoice(pCode, false); 
  2. Set the value for shouldDisplayIDFA to show the Allow tracking popup on iOS. By default, the value is true.


By employing the StartChoice() method, the user can solely view the consent dialog during the initial launch. Subsequent launches will not display the dialog if the user has previously consented unless the user uninstalls the app or clears data on his/her Android device. The next instance the popup will appear is when modifications are made in the portal, and you specify the interval after which the popup should reappear.

Force Display Consent Popup

To forcibly display the popup, utilize the ForceDisplayUI() function.

public void ForceDisplayUI() 


After invoking the StartChoice() method, use the ForceDisplayUI() method to display the popup.

Show CCPA Consent Popup

To present the CCPA consent popup, initiate the process by calling the StartChoice() method. Subsequently, invoke the ShowCCPA() method whenever you wish to display the popup. Unlike the GDPR consent popup, the ShowCCPA() popup will appear each time the method is called.

public void ShowCCPA() 

Retrieve TCString

To retrieve the TCString, employ the GetTCString() method.

public void GetTCString() 
    string TCString = ChoiceCMP.GetTCString(); 

Set LogLevel

You also have the option to specify the desired level of log output. The available log levels are as follows:

  • None: To disable logging entirely, set ChoiceCMP.ChoiceLogLevel to None. This represents the default log level and can be implemented as follows: ChoiceCMP.ChoiceLogLevel = ChoiceCMP.LogLevel.None;.
  • Error: To enable retrieving error logs, set ChoiceCMP.ChoiceLogLevel to Error. You can implement as follows: ChoiceCMP.ChoiceLogLevel = ChoiceCMP.LogLevel.Error;.
  • Debug: To receive debug and error logs, set ChoiceCMP.ChoiceLogLevel to Debug. You can implement as follows: ChoiceCMP.ChoiceLogLevel = ChoiceCMP.LogLevel.Debug;.

Subscribe to Callbacks

Subscribe to callbacks to monitor Choice events. Below is an example demonstrating how to subscribe to the callbacks within your class:

void Start() 
    ChoiceCMPManager.CMPDidLoadEvent += delegate (PingResult pingResult) 
        // Fired when the SDK has finished loading 

    ChoiceCMPManager.CMPDidErrorEvent += delegate (string error) 
        // Fired when SDK fails to load 

    ChoiceCMPManager.CMPDidShowEvent += delegate (PingResult pingResult) 
        // Fired when popup is shown 

    ChoiceCMPManager.CMPDidReceiveAdditionalConsentEvent += delegate (ACData acData) 
        // Fired when on receiving the Additional Consent 

    ChoiceCMPManager.CMPDidReceiveCCPAConsentEvent += delegate (string ccpaConsent) 
        // Fired when on receiving the CCPA Consent 

    ChoiceCMPManager.CMPDidReceiveIABVendorConsentEvent += delegate (TCData tcData) 
        // Fired when on receiving the IAB Vendor Consent 

    ChoiceCMPManager.CMPDidReceiveNonIABVendorConsentEvent += delegate (NonIABData nonIABData) 
        // Fired when on receiving the NON IAB Vendor Consent 

Set Up Android Project

Follow the instructions below to set up the Android project for Unity:

  1. To enable the Custom Gradle Main Template, navigate to your Project Settings >> Build Settings >> Player Settings.

    You can now view the mainTemplate file in your Plugins/Android folder.


  1. Incorporate the following set of dependencies into your mainTemplate.gradle file:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // Android UI and appcompat 
    implementation 'androidx.appcompat:appcompat:1.4.1' 
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3' 
    implementation 'androidx.recyclerview:recyclerview:1.2.1' 
    implementation 'androidx.cardview:cardview:1.0.0' 
    implementation 'com.google.code.gson:gson:2.10.1'

    // KTX
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1" 
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"


Setting up the iOS project

Follow the instructions below to set up the iOS project for Unity:

  1. Open Unity and navigate to File >> Build Settings. Select the iOS platform.
  2. To create the Xcode project, click File >> Build And Run.
  3. After the Xcode project is generated and opened, download the InMobi Choice iOS Framework and use the framework in the root folder of your Xcode project.
  4. Add the framework to your project (in Unity Framework and App Target).
  5. To run the project on a simulator, exclude the arm64 architecture in the Xcode build settings.
  6. Set the Enable Bitcode option to No to disable Bitcode in both the App and Unity Framework.

On This Page

Last Updated on: 06 Nov, 2023