Skip to main content

How to migrate from version prior to 4.X.X


Migration guide

Migration is the same, whatever product you use. However, to make the code and packages easier to read, select the product that corresponds to your migration needs.

First changing

The first thing you need to know about migration is that the class name has changed.

Before, we had: com.sfbx.appconsentv3.ui.AppConsentUIV3
Now we have: com.sfbx.appconsentv3.ui.AppConsentSDK

Here's the comparison

var appConsentUIV3: AppConsentUIV3? = null
appConsentUIV3 = AppConsentUIV3(
context = this,
appKey = appkey,
onReady = {
it.addNoticeListener(getNoticeListener())
it.addGeolocationListener(getGeolocationListener())
it.presentNotice(false)
}
)

More details

As you can see, the context has been removed from the parameters and the onReady callback has become mandatory.

The signature and name of the presentNotice method have also been changed to :

  1. Return a Boolean to determine whether the CMP is displayed or not.
  2. The method name becomes tryToDisplayNotice, which lets you know when you read the method that the SDK will try to display the CMP according to functional rules.

The instance

We've also changed the way CMP is collected and used.
We no longer retrieve the instance from its constructor, but only after it has been properly initialized.

In fact, if you want to use the CMP again, you can now call the getInstance method, which will return the AppConsent object if it has already been initialized (isSdkInitialized is also public).

Listeners

We used to give you the option of adding listener callbacks, but this time you define a single listener dedicated to displaying the associated notice.

Callback results remain unchanged (either success or error with a throwable parameter).

...
it.addNoticeListener(object : AppConsentNoticeListener {
override fun onConsentGiven() {
Log.i(TAG, "New consent given")
}

override fun onError(error: AppConsentError) {
Log.e(TAG, error.cause?.message ?: "Unknown error", error.cause)
}
})

New configuration

As with the CLASSIC version of our SDK (deprecated to date due to TCF2.2 requirements), we are providing you with a new parameter that allows you to choose whether you want to display the CMP in full screen or popup mode.

This parameter was added and then a new ACConfiguration component was created to make it easier to upgrade the CMP with a minimum of breaking change.

/**
* The main method, which allows you to initialize AppConsent with a default configuration or a
* custom configuration [ACConfiguration] like theme [AppConsentTheme], force the application of GRPD whatever
* the region for example or display CMP in full screen.
* By default, you will only need the [appKey] provided by the SFBX platform AND the callback [onReady].
*
* The [onReady] callback retrieves the AppConsent object once it is ready for use.
* It will enable you to use the CMP (consent management platform).
* At this point, you can either use [com.sfbx.appconsent.AppConsent] to display the CMP, or later
* use the [com.sfbx.appconsentv3.ui.AppConsentSDK.getInstance] method to retrieve the AppConsent object.
*
* @param appKey The appKey provided by SFBX when you created the notice on the web platform
* @param configuration Allows you to specify certain options related to CMP display.
* For example, full-screen display, force CMP display or
* make your own visual modifications, such as logos or your own theme.
* This is an optional field.
* @param onReady Callback that will be triggered once the communication is established
* with your account and it is ready to retrieve your configuration
*/
fun initialize(
appKey: String,
configuration: ACConfiguration,
onReady: (appConsent: com.sfbx.appconsentv3.AppConsent) -> Unit
)