Skip to content

Manual Download for MAX Mediation Networks

To receive release updates, subscribe to the AppLovin-MAX-SDK-iOS GitHub repository.

Download the Latest iOS SDK

Integrate the AppLovin SDK

The downloaded zip file contains the AppLovinSDK.xcframework file. To add the SDK to your application, drag the AppLovinSDK.xcframework file to your Xcode project. Ensure that AppLovinSDK.xcframework is included in the Frameworks, Libraries, and Embedded Content section of your Xcode project target’s settings.

Enable Xcode Flags

You must add the -ObjC flag in order for you to compile the AppLovin SDK. To enable the -ObjC flag, select File > Project Settings, go to Build Settings, search for Other Linker Flags, then click + to add -ObjC.

Add Frameworks

Link the following frameworks in your project:

  • AdSupport
  • AppTrackingTransparency
  • AudioToolbox
  • AVFoundation
  • CoreGraphics
  • CoreMedia
  • CoreMotion
  • CoreTelephony
  • Foundation
  • MessageUI
  • libz
  • SafariServices
  • StoreKit
  • SystemConfiguration
  • UIKit
  • WebKit

Enable Ad Review

To enable the MAX Ad Review service, download AppLovinQualityServiceSetup-ios.rb and move it into your project folder. Open a terminal window, cd to your project directory and run:

Terminal window
ruby AppLovinQualityServiceSetup-ios.rb

Add the SDK Key

Select File > Project Settings > Info. Click on one of the rows of Custom iOS Properties and click + to add a new row. Set the key of the new row to AppLovinSdkKey and the value to your SDK key.

You can find your SDK key in the Account > General > Keys section of the AppLovin dashboard.

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 configuration
ALSdkInitializationConfiguration *initConfig = [ALSdkInitializationConfiguration configurationWithSdkKey: @"«SDK-key»" builderBlock:^(ALSdkInitializationConfigurationBuilder *builder) {
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
}];

Example

Below is a sample integration:

// Create the initialization configuration
ALSdkInitializationConfiguration *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.plist
settings.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
}];

SKAdNetwork

Refer to the SKAdNetwork documentation for integration instructions.

Interstitial Ads

Loading an Interstitial

To load an interstitial ad, instantiate an MAInterstitialAd object with your ad unit and call loadAd(). Implement MAAdDelegate so you can be notified of when your ad is ready and other ad events.

#import "ExampleViewController.h"
#import <AppLovinSDK/AppLovinSDK.h>
@interface ExampleViewController()<MAAdDelegate>
@property (nonatomic, strong) MAInterstitialAd *interstitialAd;
@property (nonatomic, assign) NSInteger retryAttempt;
@end
@implementation ExampleViewController
- (void)createInterstitialAd
{
self.interstitialAd = [[MAInterstitialAd alloc] initWithAdUnitIdentifier: @"«ad-unit-ID»"];
self.interstitialAd.delegate = self;
// Load the first ad
[self.interstitialAd loadAd];
}
#pragma mark - MAAdDelegate Protocol
- (void)didLoadAd:(MAAd *)ad
{
// Interstitial ad is ready to be shown. '[self.interstitialAd isReady]' will now return 'YES'
// Reset retry attempt
self.retryAttempt = 0;
}
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error
{
// Interstitial ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
self.retryAttempt++;
NSInteger delaySec = pow(2, MIN(6, self.retryAttempt));
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delaySec * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self.interstitialAd loadAd];
});
}
- (void)didDisplayAd:(MAAd *)ad {}
- (void)didClickAd:(MAAd *)ad {}
- (void)didHideAd:(MAAd *)ad
{
// Interstitial ad is hidden. Pre-load the next ad
[self.interstitialAd loadAd];
}
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error
{
// Interstitial ad failed to display. AppLovin recommends that you load the next ad
[self.interstitialAd loadAd];
}
@end

Showing an Interstitial Ad

To show an interstitial ad, call showAd() on the MAInterstitialAd object that you created above.

if ( [self.interstitialAd isReady] )
{
[self.interstitialAd showAd];
}

Rewarded Ads

Loading a Rewarded Ad

To load a rewarded ad, retrieve a MARewardedAd object with your rewarded ad unit and call loadAd() on it. Implement MARewardedAdDelegate so you can be notified of when your ad is ready and other ad events.

#import "ExampleViewController.h"
#import <AppLovinSDK/AppLovinSDK.h>
@interface ExampleViewController()<MARewardedAdDelegate>
@property (nonatomic, strong) MARewardedAd *rewardedAd;
@property (nonatomic, assign) NSInteger retryAttempt;
@end
@implementation ExampleViewController
- (void)createRewardedAd
{
self.rewardedAd = [MARewardedAd sharedWithAdUnitIdentifier: @"«ad-unit-ID»"];
self.rewardedAd.delegate = self;
// Load the first ad
[self.rewardedAd loadAd];
}
#pragma mark - MAAdDelegate Protocol
- (void)didLoadAd:(MAAd *)ad
{
// Rewarded ad is ready to be shown. '[self.rewardedAd isReady]' will now return 'YES'
// Reset retry attempt
self.retryAttempt = 0;
}
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error
{
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
self.retryAttempt++;
NSInteger delaySec = pow(2, MIN(6, self.retryAttempt));
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delaySec * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self.rewardedAd loadAd];
});
}
- (void)didDisplayAd:(MAAd *)ad {}
- (void)didClickAd:(MAAd *)ad {}
- (void)didHideAd:(MAAd *)ad
{
// Rewarded ad is hidden. Pre-load the next ad
[self.rewardedAd loadAd];
}
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error
{
// Rewarded ad failed to display. AppLovin recommends that you load the next ad
[self.rewardedAd loadAd];
}
#pragma mark - MARewardedAdDelegate Protocol
- (void)didRewardUserForAd:(MAAd *)ad withReward:(MAReward *)reward
{
// Rewarded ad was displayed and user should receive the reward
}
@end

Showing a Rewarded Ad

To show a rewarded ad, call showAd() on the MARewardedAd object that you created above.

if ( [self.rewardedAd isReady] )
{
[self.rewardedAd showAd];
}

Banners and MRECs

Loading and Showing Banners and MRECs

To load an ad create a MAAdView object with your ad unit and call loadAd(). To show the ad, add the MAAdView object as a subview of your view hierarchy. Implement MAAdViewAdDelegate so you can be notified of when your ad is ready and other ad events.

#import "ExampleViewController.h"
#import <AppLovinSDK/AppLovinSDK.h>
@interface ExampleViewController()<MAAdViewAdDelegate>
@property (nonatomic, strong) MAAdView *adView;
@end
@implementation ExampleViewController
- (void)createBannerAd
{
self.adView = [[MAAdView alloc] initWithAdUnitIdentifier: @"«ad-unit-ID»"];
self.adView.delegate = self;
// Banner height on iPhone and iPad is 50 and 90, respectively
CGFloat height = (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) ? 90 : 50;
// Stretch to the width of the screen for banners to be fully functional
CGFloat width = CGRectGetWidth(UIScreen.mainScreen.bounds);
self.adView.frame = CGRectMake(x, y, width, height);
// Set background or background color for banner ads to be fully functional
self.adView.backgroundColor = BACKGROUND_COLOR;
[self.view addSubview: self.adView];
// Load the ad
[self.adView loadAd];
}
#pragma mark - MAAdDelegate Protocol
- (void)didLoadAd:(MAAd *)ad {}
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error {}
- (void)didClickAd:(MAAd *)ad {}
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error {}
#pragma mark - MAAdViewAdDelegate Protocol
- (void)didExpandAd:(MAAd *)ad {}
- (void)didCollapseAd:(MAAd *)ad {}
#pragma mark - Deprecated Callbacks
- (void)didDisplayAd:(MAAd *)ad { /* use this for impression tracking */ }
- (void)didHideAd:(MAAd *)ad { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
@end

To hide a banner or MREC, call the following:

adView.hidden = YES;
[adView stopAutoRefresh];

To show a banner or MREC, call the following:

adView.hidden = NO;
[adView startAutoRefresh];

Preparing Mediated Networks

Select the ad networks to integrate. Then follow the specific instructions below.

Manual Download for MAX Mediation Networks