> For the complete documentation index, see [llms.txt](https://docs.sfbx.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sfbx.io/configuration/step-3-notice-implementation-web-app-tv/android/unified-sdk/migrate-from-old-sdk.md).

# Migrate from Old SDK

### Updating the old repository

Formerly we had:

```kotlin
maven { 
  url = uri("https://artifactory.datalf.chat/artifactory/app-consent-v2-release")
}
```

From now on, it is necessary to:

```kotlin
maven { 
  url = uri("https://artifactory.datalf.chat/artifactory/appconsent")
}
```

### Implementation change

Previously, we had:

```kotlin
dependencies { 
    implementation("com.sfbx.appconsent:appconsent-ui-v3:X.Y.Z")
}
```

From now on, you must:

```kotlin
dependencies { 
    implementation("io.sfbx.appconsent:unifiedsdk:X.Y.Z")
}
```

### Change in integration

#### Imports

Before we had:

```kotlin
import com.sfbx.appconsentv3.*
```

Now the imports are as follows:

```kotlin
import io.sfbx.appconsent.unifiedsdk.*
```

#### Set up your SDK

Previously, the setup looked like this:

```kotlin
AppConsentSDK.initialize(
     appKey = "",
     configuration = ACConfiguration.Builder()
          .setForceApplyGDPR(true)
          .setNeedToDisplayValidationButtonsVertically(true)
          .setNeedToReplaceUrlViewerByQrCode(true)
          .setFullScreenMode(true)
          .build()
) { ... }
```

Now the setup looks like this:

```kotlin
SFBX.initialize(
     configuration = Configuration(
          appkey = "YOUR APPKEY",
          optionals = emptyMap()
     ),
     onCmpReady = { ... },
     onCmpOnError = { ... },
)
```

{% hint style="info" %}
Have you noticed that the GDPR, fullscreen, vertical buttons, and QR code fields are no longer there?

You can now configure these fields from the Notice settings on your dashboard. This will allow you to make changes directly in your CMP without having to deploy a new version of your app.

Only QrCode is available by default on TV environment
{% endhint %}

<div><figure><img src="https://4229351976-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkyFlZKFaKP4MUM0zILOg%2Fuploads%2FufYqF6cTtHJP7RYGxOPt%2FCapture%20d%E2%80%99e%CC%81cran%202026-09-02%20a%CC%80%2011.49.39.png?alt=media&amp;token=f24a5edb-f25b-4918-a28d-5aaeca9bd941" alt=""><figcaption></figcaption></figure> <figure><img src="https://4229351976-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkyFlZKFaKP4MUM0zILOg%2Fuploads%2FHjKsGEkb6vMtZECgBFdQ%2FCapture%20d%E2%80%99e%CC%81cran%202026-09-02%20a%CC%80%2011.50.10.png?alt=media&amp;token=0e00c4d1-a199-40d9-9798-7fd04f76ea83" alt=""><figcaption></figcaption></figure> <figure><img src="https://4229351976-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkyFlZKFaKP4MUM0zILOg%2Fuploads%2F2ouOkAZBg7wVXirJ3Ynq%2FCapture%20d%E2%80%99e%CC%81cran%202026-09-02%20a%CC%80%2011.50.31.png?alt=media&amp;token=bdbe1ddc-401f-47c3-b0c5-17a1a188be81" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
Please ignore the “optionals” field; it is currently a no-op field.\
The complete documentation is available in the Configuration object in your IDE.
{% endhint %}

#### Initializing the SDK

This is very similar to the old SDK (like many other libraries).

Before, we had:

1. Initialization of the SDK
2. Registration of callbacks to intercept the user's response
3. Attempt to display the CMP
4. Deletion of callbacks regardless of the result

```kotlin
AppConsentSDK.initialize(
  appKey = "YOUR_APP_KEY"
) { appConsentInitialized ->
  appConsentInitialized.setOnPresentNoticeListener(object : OnPresentNoticeListener {
    override fun presentConsentError(error: Throwable?) {
      appConsentInitialized.setOnPresentNoticeListener(null)
    }

     override fun presentConsentGiven() {
       appConsentInitialized.setOnPresentNoticeListener(null)
     }
  })
  
  if(false == appConsentInitialized.tryToDisplayNoticeFromUiContext(uiContext = this@MainActivity, force = false)) {
    appConsentInitialized.setOnPresentNoticeListener(null)
  }
}
```

Now :

1. Initializing the SDK
2. Display request (the display & consent response is returned directly in the method callbacks)

```kotlin
SFBX.initialize(
  context = this@MyActivity.context,
  configuration = Configuration(appkey = "YOUR-APP-KEY"),
  onCmpReady = { appconsent ->
    appconsent.presentNotice(
      context = context,
      onCmpDisplayed = { },
      onCmpNotDisplayed = { },
      onCmpClosed = { },
    )},
  onCmpOnError = { appconsentExceptions ->
     },
)
```

### Displaying the consent screen to your users

This allows your users to view their consent and modify it if necessary.

Before, we had:

```kotlin
AppConsentSDK.getInstance()
  ?.setOnPresentNoticeListener(object : OnPresentNoticeListener {
    override fun presentConsentError(error: Throwable?) {
      AppConsentSDK.getInstance()?.setOnPresentNoticeListener(null)
    }

    override fun presentConsentGiven() {
      AppConsentSDK.getInstance()?.setOnPresentNoticeListener(null)
    }
  })

  val isCmpDisplayed =
    AppConsentSDK.getInstance()?.tryToDisplayNotice(force = true) ?: false
  if (false == isCmpDisplayed) {
    AppConsentSDK.getInstance()?.setOnPresentNoticeListener(null)
  }
```

Now :

```kotlin
try {
    SFBX.getInstance()
} catch (_: Exception) {
    null
}?.displayLayer2(context,
    onCmpDisplayed = { },
    onCmpNotDisplayed = { },
    onCmpClosed = { },
)


// Alternatively, the following approach is more idiomatic Kotlin,
// using runCatching to handle the exception in a functional style.


runCatching {
    SFBX.getInstance()
}.onSuccess { appconsent ->
    appconsent.displayLayer2(context,
        onCmpDisplayed = { },
        onCmpNotDisplayed = { },
        onCmpClosed = { },
    )
}.onFailure {
}
```
