To receive release updates, subscribe to the AppLovin-MAX-SDK-iOS GitHub repository.
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.
Include AppLovinSDK.xcframework in the Frameworks, Libraries, and Embedded Content section of your Xcode project target’s settings.
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.
Link the following frameworks in your project:
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:
ruby AppLovinQualityServiceSetup-ios.rb
Select File > Project Settings > Info.
Click 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.
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, except ALSdkSettings which contains mutable properties that can change 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
}];
// Create the initialization configuration
let 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 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
}
⋮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
}];
// Create the initialization configuration
let 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().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.isEnabled = true
settings.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 configuration
ALSdk.shared().initialize(with: initConfig) { sdkConfig in
// Start loading ads
}Refer to the SKAdNetwork documentation for integration instructions.
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
class ExampleViewController: UIViewController, MAAdDelegate
{
var interstitialAd: MAInterstitialAd!
var retryAttempt = 0.0
func createInterstitialAd()
{
interstitialAd = MAInterstitialAd(adUnitIdentifier: "«ad-unit-ID»")
interstitialAd.delegate = self
// Load the first ad
interstitialAd.load()
}
// MARK: MAAdDelegate Protocol
func didLoad(_ ad: MAAd)
{
// Interstitial ad is ready to be shown. 'interstitialAd.isReady' will now return 'true'
// Reset retry attempt
retryAttempt = 0
}
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError)
{
// Interstitial ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
retryAttempt += 1
let delaySec = pow(2.0, min(6.0, retryAttempt))
DispatchQueue.main.asyncAfter(deadline: .now() + delaySec) {
self.interstitialAd.load()
}
}
func didDisplay(_ ad: MAAd) {}
func didClick(_ ad: MAAd) {}
func didHide(_ ad: MAAd)
{
// Interstitial ad is hidden. Pre-load the next ad
interstitialAd.load()
}
func didFail(toDisplay ad: MAAd, withError error: MAError)
{
// Interstitial ad failed to display. AppLovin recommends that you load the next ad
interstitialAd.load()
}
}To show an interstitial ad, call showAd() on the MAInterstitialAd object that you created above.
if ( [self.interstitialAd isReady] )
{
[self.interstitialAd showAd];
}
if interstitialAd.isReady
{
interstitialAd.show()
}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
class ExampleViewController : UIViewController, MARewardedAdDelegate
{
var rewardedAd: MARewardedAd!
var retryAttempt = 0.0
func createRewardedAd()
{
rewardedAd = MARewardedAd.shared(withAdUnitIdentifier: "«ad-unit-ID»")
rewardedAd.delegate = self
// Load the first ad
rewardedAd.load()
}
// MARK: MAAdDelegate Protocol
func didLoad(_ ad: MAAd)
{
// Rewarded ad is ready to be shown. '[self.rewardedAd isReady]' will now return 'YES'
// Reset retry attempt
retryAttempt = 0
}
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError)
{
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
retryAttempt += 1
let delaySec = pow(2.0, min(6.0, retryAttempt))
DispatchQueue.main.asyncAfter(deadline: .now() + delaySec) {
self.rewardedAd.load()
}
}
func didDisplay(_ ad: MAAd) {}
func didClick(_ ad: MAAd) {}
func didHide(_ ad: MAAd)
{
// Rewarded ad is hidden. Pre-load the next ad
rewardedAd.load()
}
func didFail(toDisplay ad: MAAd, withError error: MAError)
{
// Rewarded ad failed to display. AppLovin recommends that you load the next ad
rewardedAd.load()
}
// MARK: MARewardedAdDelegate Protocol
func didRewardUser(for ad: MAAd, with reward: MAReward)
{
// Rewarded ad was displayed and user should receive the reward
}
}To show a rewarded ad, call showAd() on the MARewardedAd object that you created above.
if ( [self.rewardedAd isReady] )
{
[self.rewardedAd showAd];
}
if rewardedAd.isReady
{
rewardedAd.show()
}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
class ExampleViewController: UIViewController, MAAdViewAdDelegate
{
var adView: MAAdView!
func createBannerAd()
{
adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»")
adView.delegate = self
// Banner height on iPhone and iPad is 50 and 90, respectively
let height: CGFloat = (UIDevice.current.userInterfaceIdiom == .pad) ? 90 : 50
// Stretch to the width of the screen for banners to be fully functional
let width: CGFloat = UIScreen.main.bounds.width
adView.frame = CGRect(x: x, y: y, width: width, height: height)
// Set background or background color for banner ads to be fully functional
adView.backgroundColor = BACKGROUND_COLOR
view.addSubview(adView)
// Load the first ad
adView.loadAd()
}
// MARK: MAAdDelegate Protocol
func didLoad(_ ad: MAAd) {}
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError) {}
func didClick(_ ad: MAAd) {}
func didFail(toDisplay ad: MAAd, withError error: MAError) {}
// MARK: MAAdViewAdDelegate Protocol
func didExpand(_ ad: MAAd) {}
func didCollapse(_ ad: MAAd) {}
// MARK: Deprecated Callbacks
func didDisplay(_ ad: MAAd) { /* use this for impression tracking */ }
func didHide(_ ad: MAAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
}#import "ExampleViewController.h"
#import <AppLovinSDK/AppLovinSDK.h>
@interface ExampleViewController()<MAAdViewAdDelegate>
@property (nonatomic, strong) MAAdView *adView;
@end
@implementation ExampleViewController
- (void)createMRECAd
{
self.adView = [[MAAdView alloc] initWithAdUnitIdentifier: @"«ad-unit-ID»" adlanguage: MAAdFormat.mrec];
self.adView.delegate = self;
// MREC width and height are 300 and 250 respectively, on iPhone and iPad
CGFloat width = 300;
CGFloat height = 250;
// Center the MREC
CGFloat x = self.view.center.x - 150;
self.adView.frame = CGRectMake(x, y, width, height);
// Set background or background color for MREC 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
class ExampleViewController: UIViewController, MAAdViewAdDelegate
{
var adView: MAAdView!
func createMRECAd
{
adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»", adlanguage: MAAdFormat.mrec)
adView.delegate = self
// MREC width and height are 300 and 250 respectively, on iPhone and iPad
let height: CGFloat = 250
let width: CGFloat = 300
adView.frame = CGRect(x: x, y: y, width: width, height: height)
// Center the MREC
adView.center.x = view.center.x
// Set background or background color for MREC ads to be fully functional
adView.backgroundColor = BACKGROUND_COLOR
view.addSubview(adView)
// Load the first ad
adView.loadAd()
}
// MARK: MAAdDelegate Protocol
func didLoad(_ ad: MAAd) {}
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError) {}
func didClick(_ ad: MAAd) {}
func didFail(toDisplay ad: MAAd, withError error: MAError) {}
// MARK: MAAdViewAdDelegate Protocol
func didExpand(_ ad: MAAd) {}
func didCollapse(_ ad: MAAd) {}
// MARK: Deprecated Callbacks
func didDisplay(_ ad: MAAd) { /* use this for impression tracking */ }
func didHide(_ ad: MAAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
}To hide a banner or MREC, call the following:
adView.hidden = YES;
[adView stopAutoRefresh];
adView.isHidden = true
adView.stopAutoRefresh()To show a banner or MREC, call the following:
adView.hidden = NO;
[adView startAutoRefresh];
adView.isHidden = false
adView.startAutoRefresh()Select the ad networks to integrate. Then follow the specific instructions below.
Starting from Pangle iOS adapter version 4.9.1.0.0, Pangle is no longer available in Chinese Mainland. To monetize Chinese Mainland traffic, configure the CSJ network and add the CSJ adapter. For global traffic that excludes Chinese Mainland, you can continue to use Pangle for monetization.
To support Swift for iOS versions below 12.2:

window propertyDo not remove the window property of your App Delegate file.
If you do so, InMobi’s SDK may crash.
@property (nonatomic, strong) UIWindow *window;
var window: UIWindow?If you do not want to enable Limited Data Use (LDU) mode, pass SetDataProcessingOptions() an empty array:
#import <FBAudienceNetwork/FBAudienceNetwork.h>
⋮
[FBAdSettings setDataProcessingOptions: @[]];
⋮
// Initialize MAX SDK
import FBAudienceNetwork
⋮
FBAdSettings.setDataProcessingOptions([])
⋮
// Initialize MAX SDKTo enable LDU for users and to specify user geography, call SetDataProcessingOptions() like this:
#import <FBAudienceNetwork/FBAudienceNetwork.h>
⋮
[FBAdSettings setDataProcessingOptions: @[@"LDU"] country: «country» state: «state»];
⋮
// Initialize MAX SDK
import FBAudienceNetwork
⋮
FBAdSettings.setDataProcessingOptions(["LDU"], country: «country», state: «state»)
⋮
// Initialize MAX SDKIf you use Google UMP as your CMP, you can determine whether the user has consented to Meta or not. To do so, use code like the following:
NSNumber *hasMetaConsent = [ALPrivacySettings additionalConsentStatusForIdentifier: 89];
if ( hasMetaConsent )
{
BOOL consentGiven = hasMetaConsent.boolValue;
// Set Meta Data Processing Options accordingly.
}
else
{
// AC String is not available on disk. Please check for consent status after the user completes the CMP flow.
}
let hasMetaConsent = ALPrivacySetting.additionalConsentStatus(forIdentifier: 89)
if let consentGiven = hasMetaConsent?.boolValue
{
// Set Meta Data Processing Options accordingly.
}
else
{
// AC String is not available on disk. Please check for consent status after the user completes the CMP flow.
}To learn how to implement Meta Audience Network’s “Limited Data Use” flag in California, read the Meta for Developers documentation.
Audience Network SDK 6.2.1 introduces these important requirements:
setAdvertiserTrackingEnabled flag, irrespective of the use of mediation.
This informs Meta whether it can use the data to deliver personalized ads.Info.plist so that advertisers can measure the success of ad campaigns.
Refer to the SKAdNetwork documentation for integration instructions.[sdk initializeSdkWithCompletionHandler:^(ALSdkConfiguration *sdkConfiguration)
{
if ( @available(iOS 14.5, *) )
{
// Note that App transparency tracking authorization can be checked via `sdkConfiguration.appTrackingTransparencyStatus`
// 1. Set Meta ATE flag here, THEN
}
// 2. Load ads
}];
sdk.initializeSdk { (sdkConfiguration: ALSdkConfiguration) in
if #available(iOS 14.5, *)
{
// Note that App transparency tracking authorization can be checked via `sdkConfiguration.appTrackingTransparencyStatus`
// 1. Set Meta ATE flag here, THEN
}
// 2. Load ads
}Developers and publishers who use Google AdSense, AdManager, or AdMob must use a consent management platform (CMP) that Google certifies. The CMP must integrate with IAB’s Transparency and Consent Framework when you serve ads to users in the European Economic Area (EEA) or the UK. See Privacy: “TCF v2 consent” for more information.
In your app’s Info.plist, add a GADApplicationIdentifier key.
Give this key the String value of your Google bidding and Google AdMob / Google Ad Manager App ID.

The Amazon Publisher Services SDK requires that you initialize it outside MAX SDK:
[[DTBAds sharedInstance] setAppKey: appId];
[DTBAds sharedInstance].mraidCustomVersions = @[@"1.0", @"2.0", @"3.0"];
[DTBAds sharedInstance].mraidPolicy = CUSTOM_MRAID;
Use the latest Amazon Publisher Services adapter version to avoid reporting discrepancies.
To integrate Amazon ads into MAX, you must load the Amazon ad first.
Before you load the MAX ad, pass the DTBAdResponse or DTBAdErrorInfo into the instance of MAAdView.
You can do this by calling -[MAAdView setLocalExtraParameterForKey:value:].
For auto-refreshing banner ads you need to load the ad only once.
@interface ExampleViewController ()<DTBAdCallback>
⋮
@end
@implementation ExampleViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *amazonAdSlotId;
MAAdFormat *adFormat;
if ( UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad )
{
amazonAdSlotId = @"«Amazon-leader-slot-ID»";
adFormat = MAAdFormat.leader;
}
else
{
amazonAdSlotId = @"«Amazon-banner-slot-ID»";
adFormat = MAAdFormat.banner;
}
CGSize rawSize = adFormat.size;
DTBAdSize *size = [[DTBAdSize alloc] initBannerAdSizeWithWidth: rawSize.width
height: rawSize.height
andSlotUUID: amazonAdSlotId];
DTBAdNetworkInfo *adNetworkInfo = [[DTBAdNetworkInfo alloc] initWithNetworkName: DTBADNETWORK_MAX];
DTBAdLoader *adLoader = [[DTBAdLoader alloc] initWithAdNetworkInfo: adNetworkInfo];
[adLoader setAdSizes: @[size]];
[adLoader loadAd: self];
}
- (void)onSuccess:(DTBAdResponse *)adResponse
{
// 'adView' is your instance of MAAdView
[self.adView setLocalExtraParameterForKey: @"amazon_ad_response" value: adResponse];
[self.adView loadAd];
}
- (void)onFailure:(DTBAdError)error dtbAdErrorInfo:(DTBAdErrorInfo *)errorInfo
{
// 'adView' is your instance of MAAdView
[self.adView setLocalExtraParameterForKey: @"amazon_ad_error" value: errorInfo];
[self.adView loadAd];
}
@end
import AppLovinSDK
import DTBiOSSDK
class ExampleViewController: UIViewController
{
override func viewDidLoad()
{
super.viewDidLoad()
let amazonAdSlotId: String
let adFormat: MAAdFormat
if UIDevice.current.userInterfaceIdiom == .pad
{
amazonAdSlotId = "«Amazon-leader-slot-ID»"
adFormat = MAAdFormat.leader
}
else
{
amazonAdSlotId = "«Amazon-banner-slot-ID»"
adFormat = MAAdFormat.banner
}
let rawSize = adFormat.size
let size = DTBAdSize(bannerAdSizeWithWidth: Int(rawSize.width),
height: Int(rawSize.height),
andSlotUUID: amazonAdSlotId)!
let adLoader = DTBAdLoader(adNetworkInfo: DTBAdNetworkInfo(networkName: DTBADNETWORK_MAX))
adLoader.setAdSizes([size])
adLoader.loadAd(self)
}
}
extension ExampleViewController: DTBAdCallback
{
func onSuccess(_ adResponse: DTBAdResponse!)
{
// 'adView' is your instance of MAAdView
adView.setLocalExtraParameterForKey("amazon_ad_response", value: adResponse)
adView.loadAd()
}
func onFailure(_ error: DTBAdError, dtbAdErrorInfo: DTBAdErrorInfo!)
{
// 'adView' is your instance of MAAdView
adView.setLocalExtraParameterForKey("amazon_ad_error", value:dtbAdErrorInfo)
adView.loadAd()
}
}import AppLovinSDK
import DTBiOSSDK
struct ExampleSwiftUIWrapper: UIViewRepresentable
{
func makeUIView(context: Context) -> MAAdView
{
let adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»")
adView.delegate = context.coordinator
let amazonAdSlotId: String
let adFormat: MAAdFormat
if UIDevice.current.userInterfaceIdiom == .pad
{
amazonAdSlotId = "«Amazon-leader-slot-ID»"
adFormat = MAAdFormat.leader
}
else
{
amazonAdSlotId = "«Amazon-banner-slot-ID»"
adFormat = MAAdFormat.banner
}
let rawSize = adFormat.size
let size = DTBAdSize(bannerAdSizeWithWidth: Int(rawSize.width),
height: Int(rawSize.height),
andSlotUUID: amazonAdSlotId)!
let adLoader = DTBAdLoader(adNetworkInfo: DTBAdNetworkInfo(networkName: DTBADNETWORK_MAX))
adLoader.setAdSizes([size])
adLoader.loadAd(adView)
return adView
}
}
extension ExampleSwiftUIWrapper
{
class Coordinator: DTBAdCallback
{
func onSuccess(_ adResponse: DTBAdResponse!)
{
// 'adView' is your instance of MAAdView
adView.setLocalExtraParameterForKey("amazon_ad_response", value: adResponse)
adView.loadAd()
}
func onFailure(_ error: DTBAdError, dtbAdErrorInfo: DTBAdErrorInfo!)
{
// 'adView' is your instance of MAAdView
adView.setLocalExtraParameterForKey("amazon_ad_error", value: dtbAdErrorInfo)
adView.loadAd()
}
}
}@interface ExampleViewController ()<DTBAdCallback>
⋮
@end
@implementation ExampleViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *amazonAdSlotId = @"«Amazon-MREC-slot-ID»";
DTBAdNetworkInfo *adNetworkInfo = [[DTBAdNetworkInfo alloc] initWithNetworkName: DTBADNETWORK_MAX];
DTBAdLoader *adLoader = [[DTBAdLoader alloc] initWithAdNetworkInfo: adNetworkInfo];
[adLoader setAdSizes: [[DTBAdSize alloc] initBannerAdSizeWithWidth: 300
height: 250
andSlotUUID: amazonAdSlotId]];
[adLoader loadAd: self];
}
- (void)onSuccess:(DTBAdResponse *)adResponse
{
// 'adView' is your instance of MAAdView
[self.adView setLocalExtraParameterForKey: @"amazon_ad_response" value: adResponse];
[self.adView loadAd];
}
- (void)onFailure:(DTBAdError)error dtbAdErrorInfo:(DTBAdErrorInfo *)errorInfo
{
// 'adView' is your instance of MAAdView
[self.adView setLocalExtraParameterForKey: @"amazon_ad_error" value: errorInfo];
[self.adView loadAd];
}
@end
import AppLovinSDK
import DTBiOSSDK
class ExampleViewController: UIViewController
{
override func viewDidLoad()
{
super.viewDidLoad()
let amazonAdSlotId: String = "«Amazon-MREC-slot-ID»"
let adLoader = DTBAdLoader(adNetworkInfo: DTBAdNetworkInfo(networkName: DTBADNETWORK_MAX))
adLoader.setAdSizes([DTBAdSize(bannerAdSizeWithWidth: 300,
height: 250,
andSlotUUID: amazonAdSlotId)!])
adLoader.loadAd(self)
}
}
extension ExampleViewController: DTBAdCallback
{
func onSuccess(_ adResponse: DTBAdResponse!)
{
// 'adView' is your instance of MAAdView
adView.setLocalExtraParameterForKey("amazon_ad_response", value: adResponse)
adView.loadAd()
}
func onFailure(_ error: DTBAdError, dtbAdErrorInfo: DTBAdErrorInfo!)
{
// 'adView' is your instance of MAAdView
adView.setLocalExtraParameterForKey("amazon_ad_error", value:dtbAdErrorInfo)
adView.loadAd()
}
}import AppLovinSDK
import DTBiOSSDK
struct ExampleSwiftUIWrapper: UIViewRepresentable
{
func makeUIView(context: Context) -> MAAdView
{
let adView = MAAdView(adUnitIdentifier: "«ad-unit-ID»", adFormat: MAAdFormat.mrec)
adView.delegate = context.coordinator
let amazonAdSlotId: String = "«Amazon-MREC-slot-ID»"
let adLoader = DTBAdLoader(adNetworkInfo: DTBAdNetworkInfo(networkName: DTBADNETWORK_MAX))
adLoader.setAdSizes([DTBAdSize(bannerAdSizeWithWidth: 300,
height: 250,
andSlotUUID: amazonAdSlotId)!])
adLoader.loadAd(adView)
return adView
}
}
extension ExampleSwiftUIWrapper
{
class Coordinator: DTBAdCallback
{
func onSuccess(_ adResponse: DTBAdResponse!)
{
// 'adView' is your instance of MAAdView
adView.setLocalExtraParameterForKey("amazon_ad_response", value: adResponse)
adView.loadAd()
}
func onFailure(_ error: DTBAdError, dtbAdErrorInfo: DTBAdErrorInfo!)
{
// 'adView' is your instance of MAAdView
adView.setLocalExtraParameterForKey("amazon_ad_error", value: dtbAdErrorInfo)
adView.loadAd()
}
}
}To integrate Amazon interstitial ads into MAX, you must load the Amazon ad first.
Before you load the MAX ad, pass the DTBAdResponse or DTBAdErrorInfo into the instance of MAInterstitialAd.
You can do this by calling -[MAInterstitialAd setLocalExtraParameterForKey:value:].
You must load and pass the Amazon DTBAdResponse or DTBAdErrorInfo into the MAInterstitialAd instance only once per session.
#import <AppLovinSDK/AppLovinSDK.h>
#import <DTBiOSSDK/DTBiOSSDK.h>
@interface ExampleViewController ()<DTBAdCallback>
⋮
@end
@implementation ExampleViewController
static MAInterstitialAd *interstitialAd;
static BOOL isFirstLoad;
+ (void)initialize
{
[super initialize];
interstitialAd = [[MAInterstitialAd alloc] initWithAdUnitIdentifier: @"«MAX-inter-ad-unit-ID»"];
isFirstLoad = YES;
}
- (void)loadAd
{
// If first load - load ad from Amazon's SDK, then load ad for MAX
if ( isFirstLoad )
{
isFirstLoad = NO;
DTBAdNetworkInfo *adNetworkInfo = [[DTBAdNetworkInfo alloc] initWithNetworkName: DTBADNETWORK_MAX];
DTBAdLoader *adLoader = [[DTBAdLoader alloc] initWithAdNetworkInfo: adNetworkInfo];
[adLoader setAdSizes: @[
[[DTBAdSize alloc] initInterstitialAdSizeWithSlotUUID: @"«Amazon-inter-slot-ID»"]
]];
[adLoader loadAd: self];
}
else
{
[interstitialAd loadAd];
}
}
- (void)onSuccess:(DTBAdResponse *)adResponse
{
// 'interstitialAd' is your instance of MAInterstitialAd
[interstitialAd setLocalExtraParameterForKey: @"amazon_ad_response" value: adResponse];
[interstitialAd loadAd];
}
- (void)onFailure:(DTBAdError)error dtbAdErrorInfo:(DTBAdErrorInfo *)errorInfo
{
// 'interstitialAd' is your instance of MAInterstitialAd
[interstitialAd setLocalExtraParameterForKey: @"amazon_ad_error" value: errorInfo];
[interstitialAd loadAd];
}
@end
import AppLovinSDK
import DTBiOSSDK
class ExampleViewController: UIViewController
{
private static var interstitialAd = MAInterstitialAd(adUnitIdentifier: "«MAX-inter-ad-unit-ID»")
private static var isFirstLoad = true
func loadAd()
{
// If first load - load ad from Amazon's SDK, then load ad for MAX
if Self.isFirstLoad
{
Self.isFirstLoad = false
let adLoader = DTBAdLoader(adNetworkInfo: DTBAdNetworkInfo(networkName: DTBADNETWORK_MAX))
adLoader.setAdSizes([DTBAdSize(interstitialAdSizeWithSlotUUID: "«Amazon-inter-slot-ID»")!])
adLoader.loadAd(self)
}
else
{
Self.interstitialAd.load()
}
}
}
extension ExampleViewController: DTBAdCallback
{
func onSuccess(_ adResponse: DTBAdResponse!)
{
// 'interstitialAd' is your instance of MAInterstitialAd
Self.interstitialAd.setLocalExtraParameterForKey("amazon_ad_response", value: adResponse)
Self.interstitialAd.load()
}
func onFailure(_ error: DTBAdError, dtbAdErrorInfo: DTBAdErrorInfo!)
{
// 'interstitialAd' is your instance of MAInterstitialAd
Self.interstitialAd.setLocalExtraParameterForKey("amazon_ad_error", value: dtbAdErrorInfo)
Self.interstitialAd.load()
}
}To integrate Amazon interstitial ads into MAX, you must load the Amazon ad first.
Before you load the MAX ad, pass the DTBAdResponse or DTBAdErrorInfo into the instance of MAInterstitialAd.
You can do this by calling -[MAInterstitialAd setLocalExtraParameterForKey:value:]
You must load and pass the Amazon DTBAdResponse or DTBAdErrorInfo into the MAInterstitialAd instance only once per session.
#import <AppLovinSDK/AppLovinSDK.h>
#import <DTBiOSSDK/DTBiOSSDK.h>
@interface ExampleViewController ()<DTBAdCallback>
⋮
@end
@implementation ExampleViewController
static MAInterstitialAd *interstitialAd;
static BOOL isFirstLoad;
+ (void)initialize
{
[super initialize];
interstitialAd = [[MAInterstitialAd alloc] initWithAdUnitIdentifier: @"«MAX-inter-ad-unit-ID»"];
isFirstLoad = YES;
}
- (void)loadAd
{
// If first load - load ad from Amazon's SDK, then load ad for MAX
if ( isFirstLoad )
{
isFirstLoad = NO;
DTBAdNetworkInfo *adNetworkInfo = [[DTBAdNetworkInfo alloc] initWithNetworkName: DTBADNETWORK_MAX];
DTBAdLoader *adLoader = [[DTBAdLoader alloc] initWithAdNetworkInfo: adNetworkInfo];
// Switch video player width and height values(320, 480) depending on device orientation
[adLoader setAdSizes: @[
[[DTBAdSize alloc] initVideoAdSizeWithPlayerWidth: 320 height: 480 andSlotUUID:@"«Amazon-video-inter-slot-ID»"]
]];
[adLoader loadAd: self];
}
else
{
[interstitialAd loadAd];
}
}
- (void)onSuccess:(DTBAdResponse *)adResponse
{
// 'interstitialAd' is your instance of MAInterstitialAd
[interstitialAd setLocalExtraParameterForKey: @"amazon_ad_response" value: adResponse];
[interstitialAd loadAd];
}
- (void)onFailure:(DTBAdError)error dtbAdErrorInfo:(DTBAdErrorInfo *)errorInfo
{
// 'interstitialAd' is your instance of MAInterstitialAd
[interstitialAd setLocalExtraParameterForKey: @"amazon_ad_error" value: errorInfo];
[interstitialAd loadAd];
}
@end
import AppLovinSDK
import DTBiOSSDK
class ExampleViewController: UIViewController
{
private static var interstitialAd = MAInterstitialAd(adUnitIdentifier: "«MAX-inter-ad-unit-ID»")
private static var isFirstLoad = true
func loadAd()
{
// If first load - load ad from Amazon's SDK, then load ad for MAX
if Self.isFirstLoad
{
Self.isFirstLoad = false
let adLoader = DTBAdLoader(adNetworkInfo: DTBAdNetworkInfo(networkName: DTBADNETWORK_MAX))
// Switch video player width and height values(320, 480) depending on device orientation
adLoader.setAdSizes([DTBAdSize(videoAdSizeWithPlayerWidth: 320, height: 480, andSlotUUID: "«Amazon-video-inter-slot-ID»")!])
adLoader.loadAd(self)
}
else
{
Self.interstitialAd.load()
}
}
}
extension ExampleViewController: DTBAdCallback
{
func onSuccess(_ adResponse: DTBAdResponse!)
{
// 'interstitialAd' is your instance of MAInterstitialAd
Self.interstitialAd.setLocalExtraParameterForKey("amazon_ad_response", value: adResponse)
Self.interstitialAd.load()
}
func onFailure(_ error: DTBAdError, dtbAdErrorInfo: DTBAdErrorInfo!)
{
// 'interstitialAd' is your instance of MAInterstitialAd
Self.interstitialAd.setLocalExtraParameterForKey("amazon_ad_error", value: dtbAdErrorInfo)
Self.interstitialAd.load()
}
}To integrate Amazon rewarded videos into MAX, you must load the Amazon ad first.
Before you load the MAX ad, pass the DTBAdResponse or DTBAdErrorInfo into the instance of MARewardedAd.
You can do this by calling -[MARewardedAd setLocalExtraParameterForKey:value:].
You must load and pass the Amazon DTBAdResponse or DTBAdErrorInfo into the MARewardedAd instance only once.
#import <AppLovinSDK/AppLovinSDK.h>
#import <DTBiOSSDK/DTBiOSSDK.h>
@interface ExampleViewController ()<DTBAdCallback>
⋮
@end
@implementation ExampleViewController
static MARewardedAd *rewardedAd;
static BOOL isFirstLoad;
+ (void)initialize
{
[super initialize];
rewardedAd = [MARewardedAd sharedWithAdUnitIdentifier: @"«MAX-rewarded-ad-unit-ID»"];
isFirstLoad = YES;
}
- (void)loadAd
{
// If first load - load ad from Amazon's SDK, then load ad for MAX
if ( isFirstLoad )
{
isFirstLoad = NO;
DTBAdNetworkInfo *adNetworkInfo = [[DTBAdNetworkInfo alloc] initWithNetworkName: DTBADNETWORK_MAX];
DTBAdLoader *adLoader = [[DTBAdLoader alloc] initWithAdNetworkInfo: adNetworkInfo];
// Switch video player width and height values(320, 480) depending on device orientation
[adLoader setAdSizes: @[
[[DTBAdSize alloc] initVideoAdSizeWithPlayerWidth: 320 height: 480 andSlotUUID:@"«Amazon-video-rewarded-slot-ID»"]
]];
[adLoader loadAd: self];
}
else
{
[rewardedAd loadAd];
}
}
- (void)onSuccess:(DTBAdResponse *)adResponse
{
// 'rewardedAd' is your instance of MARewardedAd
[rewardedAd setLocalExtraParameterForKey: @"amazon_ad_response" value: adResponse];
[rewardedAd loadAd];
}
- (void)onFailure:(DTBAdError)error dtbAdErrorInfo:(DTBAdErrorInfo *)errorInfo
{
// 'rewardedAd' is your instance of MARewardedAd
[rewardedAd setLocalExtraParameterForKey: @"amazon_ad_error" value: errorInfo];
[rewardedAd loadAd];
}
@end
import AppLovinSDK
import DTBiOSSDK
class ExampleViewController: UIViewController
{
private static var rewardedAd = MARewardedAd.shared(withAdUnitIdentifier: "«MAX-rewarded-ad-unit-ID»")
private static var isFirstLoad = true
func loadAd()
{
// If first load - load ad from Amazon's SDK, then load ad for MAX
if Self.isFirstLoad
{
Self.isFirstLoad = false
let adLoader = DTBAdLoader(adNetworkInfo: DTBAdNetworkInfo(networkName: DTBADNETWORK_MAX))
// Switch video player width and height values(320, 480) depending on device orientation
adLoader.setAdSizes([DTBAdSize(videoAdSizeWithPlayerWidth: 320, height: 480, andSlotUUID: "«Amazon-video-rewarded-slot-ID»")!])
adLoader.loadAd(self)
}
else
{
Self.rewardedAd.load()
}
}
}
extension ExampleViewController: DTBAdCallback
{
func onSuccess(_ adResponse: DTBAdResponse!)
{
// 'rewardedAd' is your instance of MARewardedAd
Self.rewardedAd.setLocalExtraParameterForKey("amazon_ad_response", value: adResponse)
Self.rewardedAd.load()
}
func onFailure(_ error: DTBAdError, dtbAdErrorInfo: DTBAdErrorInfo!)
{
// 'rewardedAd' is your instance of MARewardedAd
Self.rewardedAd.setLocalExtraParameterForKey("amazon_ad_error", value: dtbAdErrorInfo)
Self.rewardedAd.load()
}
}AppLovin recommends that you enable test mode for Amazon’s SDK. When you do this, you receive test ads. Enable test mode with the following calls:
[[DTBAds sharedInstance] setLogLevel: DTBLogLevelAll];
[[DTBAds sharedInstance] setTestMode: YES];
DTBAds.sharedInstance().setLogLevel(DTBLogLevelAll)
DTBAds.sharedInstance().testMode = trueYou can filter your waterfalls such that they contain only Amazon ads. To do this, navigate to Select Live Network in the Mediation Debugger and select the Amazon network.
To disable App Transport Security (ATS), add NSAppTransportSecurity to your app’s Info.plist.
Then add the key NSAllowsArbitraryLoads and set its Boolean value to YES.
Make sure this is the only key present.

Refer to the SKAdNetwork documentation for integration instructions.