SFBX/AppConsent

Requirements

  • Add the needed maven repository to your list:

    maven { // SFBX CMP
            url "https://artifactory.datalf.chat/artifactory/app-consent-v2-release"
    }
  • Add the SFBX CMP dependency to your build.gradle:

implementation 'com.sfbx.appconsent:appconsent-ui-v3:5.3.0'

Make sure, your SFBX CMP has been set up at its backend dashboard. Our support recommends certain vendors to be included in your server-side setup in order to yield optimal revenues.

Usage

Follow the instructions in the Managed Consent introduction section.

SFBX CMP needs an Activity instance when being created.

  • Create an instance of CMPAppConsent (CMPAppConsent implements CMPinterface).

  • Pass the created CMPAppConsent instance while creating the ManagedConsent using the public constructor ManagedConsent(cmp: CMP, context: Context, delegate: ManagedConsent.ManagedConsentDelegate).

private ManagedConsent managedConsent;

public void onActivityReady(Activity activity) {
    if (managedConsent == null) { //we want to do it only once
        CMP cmp = new CMPAppConsent(activity, "<APP_KEY>");
        managedConsent = new ManagedConsent(cmp, this, this);
        AATKitRuntimeConfiguration newConf = new AATKitRuntimeConfiguration();
        newConf.setConsent(managedConsent);
        AATKit.reconfigure(newConf);
        managedConsent.showIfNeeded(activity);
        OR
        managedConsent.showIfNeededOrRejected(10, activity);
    }
}

// ManagedConsentDelegate implementation
@Override
public void managedConsentNeedsUserInterface(@NonNull ManagedConsent managedConsent) {
    // CMP is loaded and ready to be shown
    // Show the CMP using active Activity
    managedConsent.showIfNeeded(<ACTIVITY_INSTANCE>);
    OR
    managedConsent.showIfNeededOrRejected(10, <ACTIVITY_INSTANCE>);
}

@Override
public void managedConsentCMPFinished(@NonNull ManagedConsent.ManagedConsentState state) {
    // The user finished his action with CMP with the state as the user chosen state
}

@Override
public void managedConsentCMPFailedToLoad(@NonNull ManagedConsent managedConsent, String error) {
    // CMP failed to load with the error message.
    // Reload the CMP using the active Activity
    managedConsent.reload(<ACTIVITY_INSTANCE>);
}

@Override
public void managedConsentCMPFailedToShow(@NonNull ManagedConsent managedConsent, String error) {
    // CMP failed to show with the error message
}

Last updated