Android

This topic outlines various InMobi CMP Android SDK callbacks, designed to empower publishers with the information needed for seamless integration and consent details retrieval. 

onCmpLoaded

Purpose

The onCmpLoaded notifies the publishers that the CMP has been intialised successfully and also provides some information in the PingReturn object.

Parameters

Attribute Data Type Description
info`(PingReturn) Object Information related to cmp version, cmp status etc.

Example

Kotlin

override fun onCmpLoaded(info: PingReturn) {
    Log.i("InmobiCmpSampleApp", "Cmp loaded successfully")
    Log.i("InmobiCmpSampleApp", "Cmp Id: ${info.cmpId}")
}

Java

@Override
public void onCmpLoaded(PingReturn info) {
 Log.i("InmobiCmpSampleApp", "Cmp loaded successfully");
 Log.i("InmobiCmpSampleApp", "Cmp Id: " + info.getCmpId()); 
}

onCmpUIShown

Purpose

The onCmpUIShown notifies the GDPR consent screen has been shown to publisher and also provides some information in the PingReturn object.

Parameters

Attribute Data Type Description
info`(PingReturn) Object Information related to cmp version, cmp status etc.

Example

Kotlin

override fun onCmpUIShown (info: PingReturn) {
    Log.i("InmobiCmpSampleApp", "Cmp UI shown successfully")
    Log.i("InmobiCmpSampleApp", "Cmp Id: ${info.cmpId}")
}

Java

@Override
public void onCmpUIShown (PingReturn info) {
 Log.i("InmobiCmpSampleApp", " Cmp UI shown successfully ");
 Log.i("InmobiCmpSampleApp", "Cmp Id: " + info.getCmpId()); 
}

onIABVendorConsentGiven

Purpose

This callback is triggered upon obtaining user consent for IAB-compliant vendors.

Parameters

Attribute Data Type Description
`tcData`TCData String Provides the consent information related to IAB vendors.

Example

Kotlin

override fun onIABVendorConsentGiven(tcData: TCData) {
// Use TCData to know the consent information related to IAB vendors
    Log.i("onIABVendorConsentGiven", tcData.gdprApplies.toString())
    Log.i("onIABVendorConsentGiven", tcData.tcString ?: "")
}

Java

@Override 
public void onIABVendorConsentGiven(TCData tcData) { 
// Use TCData to know the consent information related to IAB vendors Log.i("onIABVendorConsentGiven", String.valueOf(tcData.getGdprApplies())); Log.i("onIABVendorConsentGiven", tcData.getTcString() != null ? tcData.getTcString() : ""); 
}

`onNonIABVendorConsentGiven`

Purpose

The onNonIABVendorConsentGiven callback pertains to vendors configured in the InMobi CMP and do not automatically validate consent.

Parameters

Attribute Data Type Description
`nonIABData`NonIABData String Provides the consent information related to non- IAB vendors.

Example

Kotlin

override fun onNonIABVendorConsentGiven(nonIABData: NonIABData) {
    //Use NonIABData to know the consent information related to Non-IAB vendors
    Log.i("onNonIABVendorConsent", nonIABData.toString())
    // Use nonIabData.nonIabVendorConsents to checkout the vendor consents
    Log.i("onNonIABVendorConsent", nonIABData.nonIabVendorConsents.toString())
    Log.i("onNonIABVendorConsent", nonIABData.gdprApplies.toString())
}

Java

@Override 
public void onNonIABVendorConsentGiven(NonIABData nonIABData) { 
// Use NonIABData to know the consent information related to Non-IAB vendors Log.i("onNonIABVendorConsent", nonIABData.toString()); 
// Use nonIABData.getNonIabVendorConsents() to check out the vendor consents Log.i("onNonIABVendorConsent", nonIABData.getNonIabVendorConsents().toString()); Log.i("onNonIABVendorConsent", String.valueOf(nonIABData.getGdprApplies())); 
}

onCmpError

Purpose

The onCmpError notifies the publisher that some error has occurred and also provides information about the error in the `error` object.

Parameters

Attribute Data Type Description
`error`(ChoiceError) Object Information related to error.

Example

Kotlin

override fun onCmpError(error: ChoiceError) {
    Log.i("InmobiCmpSampleApp", "An error occurred during initialisation")
    Log.i("Error", error.message)
}

Java

@Override
public void onCmpError(ChoiceError error) {
    Log.i("InmobiCmpSampleApp", "An error occurred during initialization");
    Log.i("Error", error.getMessage());
}

onGoogleVendorConsentGiven

Purpose

The onGoogleVendorConsentGiven callback is specifically invoked if you have enabled Google Vendors in the portal.

Parameters

Attribute Data Type Description
`acData`(ACData) Object Provides consent information related to Google vendors.

Example

Kotlin

override fun onGoogleVendorConsentGiven(acData: ACData) {
    //Use ACData to know the consent information related to Google vendors
    Log.i("InmobiCmpSampleApp", acData.acString ?: "")
}

Java

@Override
public void onGoogleVendorConsentGiven(ACData acData) {
    // Use ACData to know the consent information related to Google vendors
    Log.i("InmobiCmpSampleApp", acData.getAcString() != null ? acData.getAcString() : "");
}

onCCPAConsentGiven

Purpose

The onCCPAConsentGiven notifies the GDPR consent screen has been shown to publisher and also provides some information in form of string.

Parameters

Attribute Data Type Description
`consentString`(String) String Represents the CCPA consent information received.

Example

Kotlin

override fun onCCPAConsentGiven(consentString: String) {
    // Use the string for CCPA consent
    Log.i("onCCPAConsentGiven", consentString)
}

Java

@Override
public void onCCPAConsentGiven(String consentString) {
    // Use the string for CCPA consent
    Log.i("onCCPAConsentGiven", consentString);

}

On This Page

Last Updated on: 27 Mar, 2024