InMobiChoice empowers site owners to efficiently handle consent across diverse devices and environments, including Android. The InMobiChoice Mobile CMP strictly adheres to the IAB TCF v2 standard.
Ensure a minimum Android version 5.0 (API 21) or higher for seamless operation. While not mandatory, we highly recommend using Android Studio 4+ for an optimal experience.
The CMP utilizes native UI components within a DialogFragment, providing an intuitive interface overlaying the current Activity.
The IAB TCF v2 mobile specifications securely store all consent data, utilizing SharedPreferences for robust data management.
We have UI customization capabilities with our Choice mobile SDK. This feature empowers developers to tailor color schemes and font styles for all UI components used in the Choice Mobile CMP. This ensures seamless integration with the host application's UI style. For more information on customizing styles, see UI Customization for Mobile Android.
There is an issue with the accurate display of consent rates on the Privacy Properties page. However, the complete analytical reports remain accessible through the Reports button.
Before integrating InMobi Choice into your mobile app, follow the instructions below to configure it on the dashboard:
On the Create a New App page, fill in details about your app such as name, type, logo, and the consent you wish to acquire from users. Once done, click Download SDK.
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.
.aar
file into projects/libs
directory of your application.build.gradle
file, include the following Gradle dependencies:
implementation files('libs/choice.aar')
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
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"
Ensure that the dependency versions are intercompatible.
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.0"
ChoiceCmpCallback
functionality, implement the ChoiceCmpCallback
interface.
class ChoiceSampleApp: Application(), ChoiceCmpCallback
class ChoiceSampleApp extends Application implements ChoiceCmpCallback
ChoiceCmpCallback
, implement the required methods. For detailed best practices on callbacks, see the next section.
override fun onCmpLoaded(pingReturn: PingReturn) {
/* code */
}
override fun onCmpUIShown(pingReturn: PingReturn) {
/* code */
}
override fun onIABVendorConsentGiven(tcData: TCData) {
/* code */
}
override fun onNonIABVendorConsentGiven(nonIABData: NonIABData) {
/* code */
}
override fun onCmpError(choiceError: ChoiceError) {
/* code */
}
override fun onGoogleVendorConsentGiven(acData: ACData) {
/* code */
}
override fun onCCPAConsentGiven(s: String) {
/* code */
}
@Override
public void onCmpLoaded(@NonNull PingReturn pingReturn) {
/* code */
}
@Override
public void onCmpUIShown(@NonNull PingReturn pingReturn) {
/* code */
}
@Override
public void onIABVendorConsentGiven(@NonNull TCData tcData) {
/* code */
}
@Override
public void onNonIABVendorConsentGiven(@NonNull NonIABData nonIABData) {
/* code */
}
@Override
public void onCmpError(@NonNull ChoiceError choiceError) {
/* code */
}
@Override
public void onGoogleVendorConsentGiven(@NonNull ACData acData) {
/* code */
}
@Override
public void onCCPAConsentGiven(@NonNull String s) {
/* code */
}
Application
class's onCreate
method, add the following code snippet. The startChoice
method requires the application context, your app's package ID (matching the web portal), your p-code, a delegate object, and an optional parameter for customization styles.
class ChoiceSampleApp : Application(), ChoiceCmpCallback {
override fun onCreate() {
super.onCreate()
ChoiceCmp.startChoice(
app = this,
packageId = "packageId",
pCode = "pCode",
callback = this
)
}
}
class ChoiceSampleApp extends Application implements ChoiceCmpCallback {
@Override
public void onCreate() {
super.onCreate();
ChoiceCmp.startChoice(
this,
"packageId",
"pcode",
this,
new ChoiceStylesResources()
);
}
}
For Kotlin users, the last parameter is optional. For more details, see UI Customization for Mobile Android.
ChoiceCmp.forceDisplayUI(activity)
ChoiceCmp.forceDisplayUI(activity);
The SDK actively monitors lifecycle events to ensure that consent information is readily available. If consent data is not found, the CMP will trigger automatically, prompting the user for their preferences. Subsequently, each time a user interaction with the CMP occurs, the associated callbacks will be triggered.
Implementing all three consent callbacks is imperative, even if you haven't configured all the consent features. This ensures comprehensive coverage and prevents any potential oversight in consent handling.
onIABVendorConsentGiven
method is triggered when the user consents to IAB-compliant vendors. For more information, see IAB-compliant vendors. Ideally, IAB-compliant mobile frameworks will autonomously adapt to this consent, configuring themselves accordingly. However, it's worth noting that limited IAB-compliant mobile frameworks are available. It is advisable to reach out to your vendor for further clarification. In cases where the framework is not compliant, the responsibility of handling consent falls on you. If the framework includes a setup method that is called in the onCreate
, it should be relocated to this section and executed after consent is verified. For example:
override fun onIABVendorConsentGiven(tcData: TCData) {
//Use TCData to know the consent information related to IAB vendors
}
@Override
public void onIABVendorConsentGiven(@NonNull TCData tcData) {
//Use TCData to know the consent information related to IAB vendors
}
To access the TC String from the shared preference, retrieve it by accessing the IABTCF_TCString
key from the < PackageName >_preferences
preference file upon receiving the consent.
onNonIABVendorConsentGiven
callback is triggered for vendors already configured in the portal and does not automatically verify consent. In this case, consent is provided in a binary manner: either a complete yes or no for all services. To verify consent, retrieve the specific vendor by their ID using the following method:
override fun onNonIABVendorConsentGiven(nonIABData: NonIABData) {
//Use NonIABData to know the consent information related to Non-IAB vendors
}
@Override
public void onNonIABVendorConsentGiven(@NonNull NonIABData nonIABData) {
//Use NonIABData to know the consent information related to Non-IAB vendors
}
onGoogleVendorConsentGiven
. This callback is called only if you have Google Vendors turned on in the portal. For more information, see Google’s Additional Consent Mode technical specification. Similar to the other callbacks, you should use this callback to manage the Google Vendors.
override fun onGoogleVendorConsentGiven(acData: ACData) {
//Use ACData to know the consent information related to Google vendors
}
@Override
public void onGoogleVendorConsentGiven(@NonNull ACData acData) {
//Use ACData to know the consent information related to Google vendors
}
While not essential, additional callbacks are available for debugging or advanced scenarios. One such callback is onCmpError
, which triggers whenever the CMP exits unexpectedly and fails to collect consent.
After initializing the SDK, you can present the CCPA screen by invoking the following method from ChoiceCmp
object and passing the Activity
:
ChoiceCmp.showCCPAScreen(activity)
ChoiceCmp.showCCPAScreen(activity);
Once the user gives consent in the CCPA screen, you can retrieve the IABUSPrivacy_String
upon receiving the consent from the <PackageName>_preferences
preference file.
By installing this SDK update, you agree that your Children Privacy Compliance setting remains accurate or that you will update that setting, whenever there is a change in your app's audience. You may update the app's Children Privacy Compliance settings at https://publisher.inmobi.com/my-inventory/app-and-placements.