Integration
This page shows you how to download, import, and configure the AppLovin MAX SDK.
Download the Latest SDK
You can download the SDK through CocoaPods as a dependency. If you prefer to integrate manually, follow the instructions here. If you prefer to integrate using Swift Package Manager, follow the instructions here.
The SDK requires the minimum iOS deployment target to be iOS 12.0 or above. It also requires Xcode version 15 or above.
To receive release updates, subscribe to the AppLovin iOS MAX SDK GitHub repository.
Swift Compatibility
To ensure your build is compatible with artifacts that contain Swift, set Build Settings > Always Embed Swift Standard Libraries to YES.
If you use Swift and build for iOS 12.2.0 or earlier, add /usr/lib/swift
to Build Settings > Runpath Search Paths.
This prevents issues with libswiftCore.dylib
.
CocoaPods
To integrate the AppLovin SDK through CocoaPods:
- Add the following line to your Podfile:
pod 'AppLovinSDK'
- Run the following on the command line:
Terminal window pod install --repo-update
Integrate Custom SDK Adapters
AppLovin Exchange (ALX) supports a custom adapter for LinkedIn. Integration instructions are below, and more information can be found here.
To install the adapter:
- Add the following line to your Podfile:
pod 'AppLovinDSPLinkedInAdapter'
- Run the following on the command line:
Terminal window pod install --repo-update
Enable Ad Review
To enable the MAX Ad Review service, you must log in to your AppLovin account.
Then download AppLovinQualityServiceSetup-ios.rb
and move it into your project folder.
Open a terminal window, cd
into your project folder and run:
ruby AppLovinQualityServiceSetup-ios.rb
Initialize the SDK
Create the SDK Initialization Configuration
Before you initialize the SDK, create an initialization configuration object for the SDK in your app delegate’s application:applicationDidFinishLaunching:
method.
This configuration object allows you to configure the properties that the SDK will initialize with.
These initialization properties are immutable, with the exception of ALSdkSettings
which contains mutable properties that can be changed during the lifetime of the app.
// Create the initialization configurationALSdkInitializationConfiguration *initConfig = [ALSdkInitializationConfiguration configurationWithSdkKey: @"«SDK-key»" builderBlock:^(ALSdkInitializationConfigurationBuilder *builder) {
builder.mediationProvider = ALMediationProviderMAX;
// Perform any additional configuration/setting changes}];
// Create the initialization configurationlet initConfig = ALSdkInitializationConfiguration(sdkKey: "«SDK-key»") { builder in
builder.mediationProvider = ALMediationProviderMAX
// Perform any additional configuration/setting changes}
You can find your SDK key in the Account > General > Keys section of the AppLovin dashboard.
Initialize the SDK
Initialize the AppLovin SDK with the initialization configuration object. Do this at startup. This maximizes the time the SDK can take to cache mediated network ads, which results in a better user experience.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ // Create the initialization configuration ALSdkInitializationConfiguration *initConfig = [ALSdkInitializationConfiguration configurationWithSdkKey: @"«SDK-key»" builderBlock:^(ALSdkInitializationConfigurationBuilder *builder) { builder.mediationProvider = ALMediationProviderMAX; }];
// Initialize the SDK with the configuration [[ALSdk shared] initializeWithConfiguration: initConfig completionHandler:^(ALSdkConfiguration *sdkConfig) { // Start loading ads }]; ⋮
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool{ let initConfig = ALSdkInitializationConfiguration(sdkKey: "«SDK-key»") { builder in builder.mediationProvider = ALMediationProviderMAX }
// Initialize the SDK with the configuration ALSdk.shared().initialize(with: initConfig) { sdkConfig in // Start loading ads } ⋮
Example
Below is a sample integration:
// Create the initialization configurationALSdkInitializationConfiguration *initConfig = [ALSdkInitializationConfiguration configurationWithSdkKey: @"«SDK-key»" builderBlock:^(ALSdkInitializationConfigurationBuilder *builder) { builder.mediationProvider = ALMediationProviderMAX; builder.segmentCollection = [MASegmentCollection segmentCollectionWithBuilderBlock:^(MASegmentCollectionBuilder *builder) { [builder addSegment: [[MASegment alloc] initWithKey: @(849) values: @[@(1), @(3)]]]; }];}];
// Configure the SDK settings if needed before or after SDK initialization.ALSdkSettings *settings = [ALSdk shared].settings;settings.userIdentifier = @"«user-ID»";[settings setExtraParameterForKey: @"uid2_token" value: @"«token-value»"];
// Note: you may also set these values in your Info.plistsettings.termsAndPrivacyPolicyFlowSettings.enabled = YES;settings.termsAndPrivacyPolicyFlowSettings.termsOfServiceURL = [NSURL URLWithString: @"«https://your-company-name.com/terms-of-service»"];settings.termsAndPrivacyPolicyFlowSettings.privacyPolicyURL = [NSURL URLWithString: @"«https://your-company-name.com/privacy-policy»"];
// Initialize the SDK with the configuration[[ALSdk shared] initializeWithConfiguration: initConfig completionHandler:^(ALSdkConfiguration *sdkConfig) { // Start loading ads}];
// Create the initialization configurationlet initConfig = ALSdkInitializationConfiguration(sdkKey: "«SDK-key»") { builder in builder.mediationProvider = ALMediationProviderMAX builder.segmentCollection = MASegmentCollection { segmentCollectionBuilder in segmentCollectionBuilder.add(MASegment(key: 849, values: [1, 3])) }}
// Configure the SDK settings if needed before or after SDK initialization.let settings = ALSdk.shared().settingssettings.userIdentifier = "«user-ID»"settings.setExtraParameterForKey("uid2_token", value: "«token-value»")
// Note: you may also set these values in your Info.plistsettings.termsAndPrivacyPolicyFlowSettings.isEnabled = truesettings.termsAndPrivacyPolicyFlowSettings.termsOfServiceURL = URL(string: "«https://your-company-name.com/terms-of-service»")settings.termsAndPrivacyPolicyFlowSettings.privacyPolicyURL = URL(string: "«https://your-company-name.com/privacy-policy»")
// Initialize the SDK with the configurationALSdk.shared().initialize(with: initConfig) { sdkConfig in // Start loading ads}
iOS 14 Support
In iOS 14, Apple introduced global privacy policy changes. Apple requires applications to comply with these new policies. If you fail to comply, you may lose revenue. This section explains how to comply.
SKAdNetwork
Update your app’s Info.plist
with network-specific identifiers.
See the SKAdNetwork documentation for instructions.
Consent and Data APIs
You must obtain consent from your users in certain jurisdictions on behalf of AppLovin’s monetization partners. You must also correctly pass consent values to AppLovin. To learn how to do these things, review the Privacy–Consent, Age-Related Flags, and Data APIs documentation.