Documentation Index

Fetch the complete documentation index at: https://usercentrics.document360.io/llms.txt

Use this file to discover all available pages before exploring further.

Cross-device consent sharing

Prev Next

Overview

This feature enables the clearing of previously granted user consents, which proves beneficial if your application offers a sign-out functionality.

By removing the consents granted by the user, this feature ensures a smooth transition for the next user, eliminating the necessity to reset and reinitialize the SDK.

Remote consents will not be deleted

This feature only clears the session stored on the local device; all user consents that can be retrieved using their controllerId will remain stored on our servers.

Examples of use cases

  • Sign-out and sign-in flow: If a login occurs and the current user is not associated in your system with a controllerId (which would indicate that their consents can be restored), the Clear User Session function should be called

  • Delete user data: If your app or game includes a feature to delete local user data, this method offers an optimized approach to clear user data while keeping the SDK prepared to collect new consents.

Implementation

Loaded Settings will be kept

Since this feature will not reinitialize the SDK, all the Settings loaded by the settingsId or rulesetId previously used will be kept.

Steps for implementation

  1. Call the clearUserSession API to clear the user session.

  2. Session cleanup callback: after invoking the API, verify the successful cleaning of the session. If the cleaning process fails, prompt the user to provide their consents again.

Clearing the user session

You can clear a user session in all Usercentrics supported platforms with the following code:

UsercentricsCore.shared.clearUserSession(onSuccess: { status in
    // This callback is equivalent to isReady API
}, onError: { error in
    // Handle non-localized error
}
Usercentrics.instance.clearUserSession({ status ->
    // This callback is equivalent to isReady API
}, { error ->
    // Handle non-localized error
})
try {
  final status = await Usercentrics.clearUserSession();
  // This callback is equivalent to isReady API
} catch (error) {
  // Handle non-localized error
}
import { Usercentrics } from '@usercentrics/react-native-sdk';

try {
  const status = await Usercentrics.clearUserSession();
  // This callback is equivalent to isReady API
} catch (error) {
  // Handle non-localized error
}
Usercentrics.Instance.ClearUserSession((status) => {
    // This callback is equivalent to isReady API
}, (errorString) => {
    // Handle non-localized error
});

Best practices

Avoid routine invocation

  • Ensure this API is called only when necessary, as invoking it excessively could burden your end-users' experience

  • Within the context of signing in and out, you can eliminate the need to call this API by restoring a user session directly. Check out this page for more detailed instructions