Configure PreferenceLink Android SDK
Provide identifying value to the SDK.
Before initialization:
Kotlin
LRPrivacyManager.configure(LRPrivacyManagerConfig(ACCESS_TOKEN, fallbackConfiguration, LRPreferenceLinkConfig("user@liveramp.com", null)))
Java
LRPrivacyManager.INSTANCE.configure(new LRPrivacyManagerConfig(ACCESS_TOKEN, fallbackConfiguration, new LRPreferenceLinkConfig("user@liveramp.com", null)));
If user identity has been provided during the configuration of the SDK, then consent data sync will take place during the initialization process. During the initialization it is not mandatory to identify the user. When the SDK has been initialized consent data will be present inside SharedPreferences and the SDK itself.
Note
Once identifying value has been provided to the SDK, it will be used until a new one has been provided or
clearSharedPreference()
API has been called.After initialization:
Kotlin
LRPrivacyManager.setPlConfigIdentifyingValue("user@liveramp.com")
Java
LLRPrivacyManager.INSTANCE.setPlConfigIdentifyingValue("user@liveramp.com");
Second option is to use the API function identifyUser. It will trigger async consent data synchronization. To use this function the SDK needs to be initialized.
Sync other user information (optional)
It is also possible to sync other user related data by passing it before and also after the initialization process of the SDK. That same data will be available inside the callback after sync is finished without errors.
Before initialization:
Kotlin
val data = hashMapOf<String, Any>() data["imageUrl"] = "https://www.liveramp.com/img/appmock001.png" LRPrivacyManager.configure(LRPrivacyManagerConfig(ACCESS_TOKEN, fallbackConfiguration, LRPreferenceLinkConfig("user@liveramp.com", data)))
Java
HashMap<String, Object> data = new HashMap<>(); data.put("imageUrl", "https://www.liveramp.com/img/appmock001.png"); LRPrivacyManager.INSTANCE.configure(new LRPrivacyManagerConfig(ACCESS_TOKEN, fallbackConfiguration, new LRPreferenceLinkConfig("user@liveramp.com", data)));
After initialization:
Kotlin
val data = hashMapOf<String, Any>() data["imageUrl"] = "https://www.liveramp.com/img/appmock001.png" LRPrivacyManager.setPlConfigAdditionalData(data)
Java
HashMap<String, Object> data = new HashMap<>(); data.put("imageUrl", "https://www.liveramp.com/img/appmock001.png"); LRPrivacyManager.INSTANCE.setPlConfigAdditionalData(data);
Headless Implementation
How to Use Headless Implementation
If you are using the headless version of the TCF SDK, automatic sync won’t be performed. If you want it you should call the doSync method to sync data. This method returns a PLSynchronizationStatus
, which can be:
UPDATE_ON_SERVER
UPDATE_LOCALLY
NOTHING_CHANGED
FAILURE
with error message
When to Call the doSync Method
To always have the latest consent data call doSync
method:
On give consent - data should be pushed to the server
On each fresh start of the SDK - sync should trigger - will download new TCString (if exists) and recreate data needed for running the SDK.
Kotlin
LRPrivacyManager.doSync(object : LRPLSyncCallback { override fun invoke(data: PlSubjectData?, status: PLSynchronizationStatus, error: Error?) { when(status){ UPDATE_ON_SERVER -> { // Do something } UPDATE_LOCALLY -> { // Do something } NOTHING_CHANGED -> { // Do something } FAILURE -> { // Do something } } } })
Java
LRPrivacyManager.INSTANCE.doSync((data, status, error) -> { switch (status) { case UPDATE_ON_SERVER: // Do something break; case UPDATE_LOCALLY: // Do something break; case NOTHING_CHANGED: // Do something break; case FAILURE: // Do something break; } });
Clearing Consent Data
There is a possibility to clear all consent related data inside SharedPreferences. Use cases can vary, f.e. when the user logs out and old consent is not valid anymore.
After calling this API, the last stored user identity will be cleared.
Kotlin
LLrPrivacyManager.clearSharedPreference()
Java
LRPrivacyManager.INSTANCE.clearSharedPreference();
If the identifier for a new user is provided, clearing of old consent data is done automatically, after SDK initialization, or identifyUser
API call.