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.
- SDK CLEAR
- SDK TV
First changing
The first thing you need to know about migration is that the class name has changed.
- SDK CLEAR
- SDK TV
Before, we had: com.sfbx.appconsentv3.ui.AppConsentUIV3
Now we have: com.sfbx.appconsentv3.ui.AppConsentSDK
Before, we had: com.sfbx.appconsent.tv.AppConsentTV
Now we have: com.sfbx.appconsent.tv.AppConsentSDK
Here's the comparison
- SDK CLEAR
- SDK TV
- Before
- Now
var appConsentUIV3: AppConsentUIV3? = null
appConsentUIV3 = AppConsentUIV3(
context = this,
appKey = appkey,
onReady = {
it.addNoticeListener(getNoticeListener())
it.addGeolocationListener(getGeolocationListener())
it.presentNotice(false)
}
)
AppConsentSDK.initialize(
appKey = appkey,
onReady = {
it.setOnPresentNoticeListener(getNoticeListenerClear())
it.setOnPresentGeolocationNoticeListener(getGeolocationNoticeListenerClear())
it.tryToDisplayNotice(false)
}
)
- Before
- Now
var appConsentTV: AppConsentTV? = null
appConsentTV = AppConsentTV(
context = this,
appKey = appkey
) {
it.addNoticeListener(object : AppConsentNoticeListener {
override fun onConsentGiven() {
Log.i("MainActivity", "Consent given")
}
override fun onError(error: AppConsentError) {
Log.e(
"MainActivity",
"Consent error:" + error.cause?.message
)
}
})
it.presentNotice(false)
}
AppConsentSDK.initialize(
appKey = appKey
) {
it.setOnPresentNoticeListener(object : OnPresentNoticeListener {
override fun presentConsentGiven() {
Log.i("MainActivity", "Consent given")
}
override fun presentConsentError(error: Throwable?) {
Log.e(
"MainActivity",
"Consent error:" + error?.cause?.message
)
}
})
it.tryToDisplayNotice(false).takeIf { !it }?.let {
Log.i("The CMP didn't displayed because of no need to do that (maybe language, no need to update, etc.)")
}
}
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 :
- Return a
Boolean
to determine whether the CMP is displayed or not. - 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).
- Before
- Now
...
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)
}
})
...
it.setOnPresentNoticeListener(object : OnPresentNoticeListener {
override fun presentConsentGiven() {
Log.i(TAG, "New consent given")
}
override fun presentConsentError(error: Throwable?) {
Log.e(TAG, error?.message ?: "Unknown error", error)
}
})
New configuration
- SDK CLEAR
- SDK TV
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
)
The 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] or force the application of GRPD whatever
* the region for example.
* 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.appconsent.tv.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, 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.appconsent.AppConsent) -> Unit
)