Unity SDK Integration
Integrating the SDK
Download the Latest Unity Plugin
Download the plugin manually: Download Unity Package
Import the Plugin into Unity
Take the following steps to import the plugin you downloaded:
- In Unity, select Assets > Import Package > Custom Package
- Choose the Unity Plugin file you downloaded.
- In the Import Unity Package dialog, click Import.
Requirements
- Unity 2018.2 or later.
- For Android builds, the AppLovin MAX plugin requires that you enable Jetifier. To enable Jetifier, take the following steps:
- In Unity, select Assets > External Dependency Manager > Android Resolver > Settings.
- In the Android Resolver Settings dialog that appears, check Use Jetifier.
- Click OK.
- For iOS builds:
- Building with bitcode is no longer supported. Apple deprecated Bitcode in Xcode 14.
- The AppLovin MAX plugin requires CocoaPods. Install CocoaPods by following the instructions at [the CocoaPods Getting Started guide](https://guides.cocoapods.org/using/getting-started.html#getting-started).
- Call all AppLovin MAX APIs on the main thread.
iOS 14 Support
SKAdNetwork
The Unity Plugin automatically updates your app’s Info.plist
with network-specific identifiers.
Initialize the SDK
Attach the OnSdkInitializedEvent event handler, then set the SDK key and initialize the SDK as soon as your app launches. The following code sample demonstrates this:
MaxSdkCallbacks.OnSdkInitializedEvent += (MaxSdkBase.SdkConfiguration sdkConfiguration) => {// AppLovin SDK is initialized, start loading ads};MaxSdk.SetSdkKey("LViME7X7lxKv-i-F_7zqiS5mftIkLozQDU3EVbAPn80KLVP7ImNA15ows7wdxZeVHHT-R_lIJO9TwH5bAxm7_N");MaxSdk.InitializeSdk();
Ad assets that are fully cached result in a better user experience. For that reason, always initialize the AppLovin SDK on startup. This gives mediated networks the maximum amount of time to cache ads. This is especially important with video ads.
Enable Creative Debugger
MaxSdk.SetCreativeDebuggerEnabled(true);
Integrating Mediation Networks
Android
Add Your Google Bidding and Google AdMob App IDs
- Open the Integration Manager (AppLovin > Integration Manager).
- Install the latest Google bidding and Google AdMob adapter:
- Click Install in the Actions column next to Google bidding and Google AdMob in the Mediated Networks section of the Integration Manager.
- Click Import in the Import Unity Package dialog.
- Two new fields for your App IDs will appear in the Mediated Networks section of the Integration Manager. Enter the corresponding values there.
Gradle Errors
Google AdMob requires Android Gradle plugin version 4.2.0 or higher and Gradle version 6.7.1 or higher.
Android Manifest Merging Errors
Several network SDKs use the <queries>
element in their bundled Android Manifest files. If you use an incompatible version of the Android Gradle plugin, this causes some build errors. To fix this error, upgrade to one of the following versions of Android Gradle plugin.
iOS
Add Your Google Bidding and Google AdMob App IDs
- Open the Integration Manager (AppLovin > Integration Manager).
- Install the latest Google bidding and Google AdMob adapter:
- Click Install in the Actions column next to Google bidding and Google AdMob in the Mediated Networks section of the Integration Manager.
- Click Import in the Import Unity Package dialog.
- Two new fields for your App IDs will appear in the Mediated Networks section of the Integration Manager. Enter the corresponding values there.
Integration Manager
You can access the AppLovin Integration Manager from your Unity IDE. It allows you to install or upgrade mediation adapters and the mediation plugin itself.
To launch the Integration Manager, select AppLovin > Integration Manager from the Unity menu bar. This displays a pop up window with a list of available mediation networks. You have to add listed mediation networks below from the displayed list. You can Install or Upgrade ad networks by clicking buttons in the Action column.
- Amazon
- Fyber
- Admob
- AdManager
- InMobi
- Mintegral
- Smaato
- Pangle
- Unity
- Vungle
- Yandex
Enabling MAX Terms and Privacy Policy Flow - GDPR
- In Unity, select AppLovin > Integration Manager. The AppLovin Integration Manager dialog appears.
- In Privacy Settings check Enable MAX Terms and Privacy Policy Flow.
- You must include values for your Privacy Policy URL and the base User Tracking Usage Description. The AppLovin Integration Manager will populate the English (base) User Tracking Usage Description and a variety of localizations of that description with default values for you. The Terms of Service URL value is optional.
- Close the AppLovin Integration Manager dialog.
Integration
The SDK presents the consent flow when you initialize the SDK. When the user completes the flow, the SDK calls your initialization-completion callback.
Localizing NSUserTrackingUsageDescription
The AppLovin MAX Unity plugin includes a default set of User Tracking Usage Descriptions. If you wish to override them, check the Override Default User Tracking Usage Description setting in the Integration Manager and enter your desired descriptions.