Initialize the iOS SDK
Once the SDK has been added to your project, you will need to initialize it. The initialization process will run on a background thread. This will prepare the SDK for interactions with the user, and your application.
SDK initialization requires a Configuration ID which is generated in Console. To learn more, see ATS Mobile SDK.
Consent Requirements
The SDK will automatically perform a geolocation check to ensure consent is properly set for GDPR and CCPA. Learn what this means for your application below:
To successfully initialize and use the SDK, user consent needs to be present per IAB standards (ie: in
UserDefaults
).The SDK will fail to initialize if there is no consent given for TCF purposes 1 to 10 and if LiveRamp is not listed as a vendor (ID 97).
If you are running the SDK outside of the GDPR and CCPA legislations, command the SDK to proceed without checking for consent (Swift):
LRAts.shared.hasConsentForNoLegislation = true
.Dynamic TCF and CCPA consent monitoring and handling is applied. This ensures if consent is revoked, SDK will reset (clear cached data) and all SDK-related APIs will stop working. The SDK will automatically re-initialise and APIs will work again if consent is given during lifecycle of the application.
For iOS devices, LiveRamp requires the user to select Allow Tracking for envelopes to be successfully fetched.
Learn more about consent requirements and best practices for each region during initialization.
How to Initialize the iOS SDK
Import the SDK module to where you want to use it.
Swift
import LRAtsSDK
Objective-C
#import <LRAtsSDK/LRAtsSDK-Swift.h>
(Optional, but recommended) Implement the SDK delegate methods. This will allow the host application to track the SDK initialization status.
Swift
LRAts.shared.delegate = self
Objective-C
[[LRAts shared] delegate] = self;
Create configuration object by providing your Config ID (
appID
).Swift
let lrAtsConfiguration = LRAtsConfiguration(appId: <#String#>)
Objective-C
LRAtsConfiguration *lrAtsConfiguration = [[LRAtsConfiguration alloc] initWithAppId:<#(NSString * _Nonnull)#>];
Initialize SDK with
LRAtsConfiguration
object. The initialization runs on a background thread to avoid blocking your UI.Note
Your application must check for ATT consent before initializing our SDK.
Swift
LRAts.shared.initialize(with: lrAtsConfiguration) { success, error in if success { print("SDK is Ready") } else { print("SDK init error: \(String(describing: error))") } }
Objective-C
[[LRAts shared] initializeWith:lrAtsConfiguration completion:^(BOOL success, NSError * _Nullable error) { if (success) { NSLog(@"init successful"); } else { NSLog(@"init failure"); } }]
Caution
After the initialization process is complete, if the ATS placement tied to the Config ID is still not yet approved, the SDK will return fake data which should only be used for testing. Information regarding the placement status can be found in the log output of the SDK.