Configure PreferenceLink iOS SDK
Provide identifying value to the SDK.
identifyingValue
is a unique identifier used for synchronization with PreferenceLink. It can be set via the configure method ofLRPrivacyManager
or any time using preferenceLink property of LRPrivacyManager.shared instance.Configuration method
Swift
let prefLinkConfig = LRPreferenceLinkConfig(identifyingValue: <#String or Int#>) let config = LRPrivacyManagerConfig(appId: <#String#>, fallbackConfiguration: <#LRConfiguration#>, preferenceLinkConfig: prefLinkConfig) LRPrivacyManager.configure(with: config)
Object-C
LRPreferenceLinkConfig *prefLinkConfig = [[LRPreferenceLinkConfig alloc] initWithIdentifyingValue:<#identifying value#> additionalData:<#additional data#>]; LRPrivacyManagerConfig *config = [[LRPrivacyManagerConfig alloc] initWithAppId:<#app id#> fallbackConfiguration:<#fallback configuration#> preferenceLinkConfig:prefLinkConfig]; [LRPrivacyManager configureWith:config];
If the identifying value has been provided during the configuration of the SDK, then consent data sync will take place during the initialization process. It is not mandatory to provide the identifying value in this phase. When the SDK has been initialized, consent data will be made available inside UserDefaults and the SDK itself.
Note
Once the identifying value has been provided to the SDK, it will be used until a new one has been provided or
clearUserDefaults()
API has been called.Property
Swift
LRPrivacyManager.shared.preferenceLink.identifyingValue = <#String or Int#>
Object-C
[[[LRPrivacyManager shared] preferenceLink] setIdentifyingValue:<#identifying value#>];LLRPrivacyManager.INSTANCE.setPlConfigIdentifyingValue("user@liveramp.com");
Note
identifyingValue
can be either String or Int. Be noted that settingidentifyingValue
this way will trigger synchronization with Preference Link.
Sync other user information (optional)
It is also possible to synchronize additional data by providing it during the configure method of LRPrivacyManager or at any time using preferenceLink property of LRPrivacyManager.shared instance.
Dictionary values must be JSONSerializable.
Objective-C acceptable objects are: NSString, NSNumber, NSArray, NSDictionary, or NSNull.
Swift acceptable objects are: String, Int, Float, Array, Dictionary, Bool
To sync Date, Enum and other object types use String representation
Configuration method
Swift
let additionalData: [String: Any] = ["avatarURL": "https://google.com/images"] let prefLinkConfig = LRPreferenceLinkConfig(identifyingValue: <#String or Int#>, additionalData: additionalData) let config = LRPrivacyManagerConfig(appId: <#T##String#>, fallbackConfiguration: <#T##LRConfiguration#>, preferenceLinkConfig: prefLinkConfig) LRPrivacyManager.configure(with: config)
Object-C
NSDictionary<NSString *, id> *additionalData = @{ @"avatarURL": @"https://google.com/images" }; LRPreferenceLinkConfig *prefLinkConfig = [[LRPreferenceLinkConfig alloc] initWithIdentifyingValue:<#identifying value#> additionalData:additionalData]; LRPrivacyManagerConfig *config = [[LRPrivacyManagerConfig alloc] initWithAppId:<#app id#> fallbackConfiguration:<#fallback configuration#> preferenceLinkConfig:prefLinkConfig]; [LRPrivacyManager configureWith:config];
Property
Swift
let additionalData: [String: Any] = ["avatarURL": "https://google.com/images"] LRPrivacyManager.shared.preferenceLink.additionalData = additionalData
Object-C
NSDictionary<NSString *, id> *additionalData = @{ @"avatarURL": @"https://google.com/images" }; [[[LRPrivacyManager shared] preferenceLink] setAdditionalData: additionalData];
Synchronization will occur with the next synchronization of consent data. To trigger sync manually, call
LRPrivacyManager.shared.doSync()
.
Headless Implementation
How to Use Headless Implementation
If you are using a headless version of the TCF SDK, automatic sync won’t be performed. To synchronize consent data with Preference Link you should call LRPrivacyManager.shared.doSync()
method. This method returns a LRPLSyncCallback
which has the following information.
PLSynchronizationStatus
nothingChanged
updatedOnServer
updatedLocally
Failure
Additional data represented as [String: Any] that are synchronized with PreferenceLink (see step 3 above)
Optional Error, if any
If PreferenceLink Sync is disabled in the console, synchronization won’t be performed even if identifyingValue and additionalData are provided to the SDK. If you want to call doSync()
with the headless implementation you must enable the PreferenceLink Sync in the console
When to Call the doSync Method
When consent changes — data will be pushed to the server
On each SDK fresh start — will download new TCString (if exists) and recreate data needed for SDK
Before presenting consent wall — will download new TCString (if exists) and recreate data needed for SDK
Clearing Consent Data
There is a possibility to clear all consent related data inside UserDefaults. Possible 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 identifyingValue for PreferenceLink Sync will be cleared as well.
Swift
LRPrivacyManager.shared.clearUserDefaults()
[[LRPrivacyManager shared] clearUserDefaults];
If identifyingValue is changed, clearing of old consent data is done automatically.