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()); 
}

onCMPUIStatusChanged

Purpose

The onCMPUIStatusChanged notifies when the CMP UI status is changed. Whenever there is any change made to the CMP UI, this callback will be called.

Parameters

Attribute Data Type Description
`status`(DisplayInfo) Object Provides information related to CMP UI and the regulation shown.

Example

Kotlin

override fun onCMPUIStatusChanged(status: DisplayInfo) {
    //Use onCMPUIStatusChanged to know the information related to CMP UI.
    Log.i("InmobiCmpSampleApp", status.displayStatus)
}

Java

@Override
public void onCMPUIStatusChanged(DisplayInfo displayInfo) {
    //Use onCMPUIStatusChanged to know the information related to CMP UI.
    Log.i("InmobiCmpSampleApp", displayInfo.getDisplayStatus());
}

onReceiveUSRegulationsConsent

Purpose

The onReceiveUSRegulationsConsent notifies that the user has finished giving or updating consent to an MSPA regulation.

Parameters

Attribute Data Type Description
`usRegulationData`(USRegulationData) Object Provides consent information related to MSPA regulation.

Example

Kotlin

override fun onReceiveUSRegulationsConsent(usRegulationData: USRegulationData) {
    //Use USRegulationData to know the consent information related to MSPA regulation.
    Log.i("InmobiCmpSampleApp", usRegulationData.gppString)
}

Java

@Override
public void onReceiveUSRegulationsConsent(USRegulationData usRegulationData) {
    //Use USRegulationData to know the consent information related to MSPA regulation.
    Log.i("InmobiCmpSampleApp", usRegulationData.getGppString());
}

onUserMovedToOtherState

Purpose

The onUserMovedToOtherState notifies that the applicable regulation is MSPA and user moved to another state due to which the applicable regulation is changed

Example

Kotlin

override fun onUserMovedToOtherState() {
    // Use onUserMovedToOtherState to know when the user has moved to another US state.
}

Java

@Override
public void onUserMovedToOtherState() {
    // Use onUserMovedToOtherState to know when the user has moved to another US state.
}

onActionButtonClicked

Purpose

The onActionButtonClicked notifies when the user has clicked any of the action buttons related to Consent or Pay on the CMP UI.

Parameters

Attribute Data Type Description
`actionButton`(ActionButton) Object Provides information related to action buttons of Consent or Pay.

Example

Kotlin

override fun onActionButtonClicked(actionButton: ActionButton) {
    //Use onActionButtonClicked to know the information related to action buttons of Cosnent or Pay.
    Log.i("InmobiCmpSampleApp", "onActionButtonClicked: $actionButton")
}

Java

@Override
public void onActionButtonClicked(ActionButton actionButton) {
    //Use onActionButtonClicked to know the information related to action buttons of Cosnent or Pay.
    Log.i("InmobiCmpSampleApp", "onActionButtonClicked: "+actionButton);
}

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 when the user has finished giving consent to a CCPA regulation.

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: 17 Feb, 2025