Skip to content

Restoring a User Session & Cross-Device Consent Sharing

Premium Feature

Cross-Device Consent Sharing is a Premium Feature that is only enabled on request. Please reach out to your Customer Success Manager for more information.

CCPA is not supported

Cross-Device Consent Sharing is not supported for CCPA. The consent collected for CCPA is only meant for the device the consent was given in.

A controllerID is a Usercentrics generated ID, used to identify a user's consent history.

In the moment that a user provides consent, the SDK will generate a controllerID that identifies that specific user to it's privacy choices. This ID will be stored locally and available to you after a user gives consent:

banner.showFirstLayer(...) { userResponse in
    let controllerID = userResponse.controllerId
}
banner.showFirstLayer(...) { userResponse ->
    val controllerId = userResponse?.controllerId
}
final userResponse = await Usercentrics.showFirstLayer(...);
val controllerId = userResponse?.controllerId
import { Usercentrics } from '@usercentrics/react-native-sdk';

const userResponse = await Usercentrics.showFirstLayer(...);
const controllerId = response.controllerId;

or you can get it by calling getControllerId() after the initialization:

let controllerID = UsercentricsCore.shared.getControllerId()
val controllerId = Usercentrics.instance.getControllerId()
final controllerId = await Usercentrics.getControllerId();
import { Usercentrics } from '@usercentrics/react-native-sdk';

const controllerId = await Usercentrics.getControllerId();

You can now take this ID, and restore a user session in another Usercentrics supported platform, such as iOS, Android, TV, Web or Unity. By using the method restoreUserSession and passing the controllerID:

UsercentricsCore.shared.restoreUserSession(controllerId: controllerId) { status in
    // This callback is equivalent to `isReady`
    if status.shouldCollectConsent {
        // Collect Consent
    } else {
        // Apply consent with status.consents
    }
} onFailure: { error in
    // Handle non-localized error
}
Usercentrics.instance.restoreUserSession(controllerId, { status ->
    // This callback is equivalent to `isReady`
    if (status.shouldCollectConsent) {
        // Collect Consent
    } else {
        // Apply consent with status.consents
    }
}, { error ->
    // Handle non-localized error
})
try {
  final status = Usercentrics.restoreUserSession(controllerId: controllerId);

  if (status.shouldCollectConsent) {
    // Collect Consent
  } else {
    // Apply consent with status.consents
  }
} catch (error) {
  // Handle non-localized error
}
import { Usercentrics } from '@usercentrics/react-native-sdk';

try {
  const status = Usercentrics.restoreUserSession(controllerId: controllerId);

  if (status.shouldCollectConsent) {
    // Collect Consent
  } else {
    // Apply consent with status.consents
  }
} catch (error) {
  // Handle non-localized error
}