Unity Plugin Integration
Unity LevelPlay mediation supports Unity version 2017.2 +, and Android operating systems version 4.1 (API level 16)+.
The download, use and access to the SDK is subject to the ironSource Platform Online Terms and Conditions. If you do not agree to the terms of ironSource Mobile SDK Publisher Online Terms & Conditions, do not download, access, or use the SDK, or the underlying services.
To be compatible with iOS 14, ironSource released SDK 7+ with support for SKAdNetwork attribution. You can learn more about updating to SDK 7 here.
Learn more about adapters support for AndroidX and iOS 14.
Unity Integration Manager
Using the Integration Manager tool, you can download ironSource SDK and adapters directly from the Unity Development Platform. If you already have Unity integration, please follow the steps here.
Step 1. Add the LevelPlay Unity package to your project
Follow these steps to add the IronSource Unity Package to your project:
- Download Unity Plugin Version 8.5.1
- Make sure your Unity project is opened and import the Unity package.
- Double-click on the extracted file; the different files will be populated automatically as shown below:
Unity LevelPlay demo app
The Integration Demo application demonstrates how to integrate Unity LevelPlay mediation in your app
Download Unity Demo Application
Step 2. Unity Integration Manager – Recommended
Install the adapters of your preferred ad networks. Make sure to follow the ad network integration guides on the menu to your left to properly set up the ad networks.
Pre-requisites
- Unity Developer Version 2017.2 or above
- For iOS – Cocoapods applied
Manage SDK versions
Once you’ve updated your Unity package for the new SDK and Integration Manager, you’ll be able to view the Ads Mediation sub-menu in the Unity menu bar.
To upgrade your SDK or Adapter versions:
- Go to Ads Mediation > Integration Manager
- Choose “Install” or “Update”
If you already have the latest version of ironSource SDK or Adapters, the action button will be changed to “Updated”, and will be disabled.
Android
To apply your changes, make sure you use the “Resolve” process. This will download all relevant artifacts, according to your choices.
Manual resolve
Go to: Assets → Mobile Dependency Manager → Android Resolver → Resolve
This action should be performed after each change in the LevelPlay Integration Manager.
If you’re using Automatic Resolve, all updates will be performed when closing the integration manager window.
For Gradle users
If you’re using LevelPlay Integration Manager for Unity, you will be able to avoid downloading the Android artifacts into your project. Instead, the artifacts will be added to your gradle file during the compilation.
To enable this process, follow these steps:
- Go to: Assets → Mobile Dependency Manager → Android Resolver → Settings
- Select “Patch mainTemplate.gradle”
- Save your changes, by pressing “OK”
iOS
Make sure that Cocoapods is installed:
Go to: Assets → Mobile Dependency Manager → iOS Resolver → Install Cocoapods
Step 3. Additional settings for iOS
Add Ad-Support.framework to your Xcode project
Our Unity Plugin usually adds all the required frameworks automatically. In some cases, the AdSupport.framework can’t be added automatically using Unity 5.6. Verify if the framework has been added and in the case it has not been added automatically, make sure to add it manually.
SKAdNetwork support
To enable the display of ironSource network ads while using SDK 7+, make sure to include the ironSource ad network ID in your app property list file (Info.plist).
- Select Info.plist in the Project navigator in Xcode
- Click the Add button (+) beside a key in the property list editor and press Return
- Type the key name SKAdNetworkItems
- Choose Array from the pop-up menu in the Type column
- Create a dictionary item, and below it a single sting item
- Enter Key name SKAdNetworkIdentifier, and the key value:
su67r6k2v3.skadnetwork
You can also add SKAdNetworkIdentifier to your Info.plist, by using this code:
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>su67r6k2v3.skadnetwork</string>
</dict>
</array>
For more information on editing the property list, see the Xcode documentation.
Universal SKAN Reporting
To receive copies of winning install-validation postbacks from all of the demand sources for your advertised app, add the NSAdvertisingAttributionReportEndpoint key in your app’s Info.plist.
- Select Info.plist in the Project navigator in Xcode
- Click the Add button (+) beside a key in the property list editor and press Return
- Type the key name NSAdvertisingAttributionReportEndpoint
- Choose String from the pop-up menu in the Type column
- Type the URL: https://postbacks-is.com
Learn more about Universal SKAN reporting here.
App transport security settings
To ensure uninterrupted support for ironSource ad delivery across all mediation networks, it’s important to make the following changes in your info.plist:
- Add in a dictionary called ‘NSAppTransportSecurity‘. Make sure you add this dictionary on the ‘Top Level Key‘.
- Inside this dictionary, add a Boolean called ‘NSAllowsArbitraryLoads‘ and set it to YES.
- Make sure that your info.plist does not contain any other exceptions besides ‘NSAllowsArbitraryLoads‘, as this might create a conflict.
- Find more information on ATS here.
Step 4. Additional setup for Android
Apps updating their target API level to 31 (Android 12) will need to declare a Google Play services normal permission in the manifest file as follows:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
Read more about Google Advertising ID changes here.
Unity 2020 Requirements
If you are using Unity 2020+, add the following gradle properties to android/gradle.properties:
android.enableDexingArtifactTransform=false
Step 5. Manual integration
As an alternative to Unity Integration Manager, you can manually integrate ironSource SDK.
Android manual integration
- Download Android SDK Version 8.5.0
- Copy .aar file to /Assets/Plugins/Android
Google identifier permissions
ironSource SDK requires google play services Basement and google play services Identifier, while other networks may also require additional google play services.
Add the Play Services dependencies into the dependencies block, to allow GAID and APP Set ID information to be retrieved.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-appset:16.0.0'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation 'com.google.android.gms:play-services-basement:17.1.1'
}
Learn more about Google’s app set id here.
iOS manual integration
- Download iOS SDK Version 8.5.1
- Unzip the file and add IronSource.framework into /Assets/Plugins/iOS
Step 6. Initialize the ad units
- ironSource supports optional SDK settings such as UserID and Segments that must be configured before you initialize the SDK. See our guide on Advanced Settings for setup instructions
- If you plan to get user authorization (iOS 14) using a pop-up whenever your app is launched, we recommend that you perform this action before you init ironSource SDK. You can learn more about App Tracking Transparency on Apple’s documentation
- If you don’t ask for user authorization (iOS 14) upon app launch, init the ironSource SDK immediately upon launch
- If you’re serving the Offerwall ad unit or using server-to-server callbacks to reward your users with ironSource rewarded ad units, set the UserID
Application State
First, you’ll need to pass the state of the application by executing the following event function during the Application Lifecycle.
Call onApplicationPause in each of the Unity Scenes:
void OnApplicationPause(bool isPaused) { IronSource.Agent.onApplicationPause(isPaused); }
Init the plugin and ad units
You can initialize the plugin in two ways. We recommend the first method as it will fetch the specific ad units you define.
- This method will init the specific ad units mentioned in the adUnits parameter:
IronSource.Agent.init (YOUR_APP_KEY, IronSourceAdUnits.REWARDED_VIDEO, IronSourceAdUnits.INTERSTITIAL, IronSourceAdUnits.OFFERWALL, IronSourceAdUnits.BANNER);
When using this init approach, you can now initialize each ad unit separately at different touchpoints in your app flow in one session.
//For Rewarded Video IronSource.Agent.init (YOUR_APP_KEY, IronSourceAdUnits.REWARDED_VIDEO); //For Interstitial IronSource.Agent.init (YOUR_APP_KEY, IronSourceAdUnits.INTERSTITIAL); //For Offerwall IronSource.Agent.init (YOUR_APP_KEY, IronSourceAdUnits.OFFERWALL); //For Banners IronSource.Agent.init (YOUR_APP_KEY, IronSourceAdUnits.BANNER);
- Alternatively, you can init the SDK as detailed below and the SDK will init the ad units you’ve configured on the ironSource platform:
IronSource.Agent.init (YOUR_APP_KEY);
ironSource Init Complete Listener
The ironSource SDK fires postback to inform you that the ironSource SDK was initialized successfully, for ironSource SDK 7.2.1+ . This listener will provide you an indication that the initialization process was completed, and you can start loading ads. The callback will be sent once per session, and will indicate the first initialization of the SDK.
IronSourceEvents.onSdkInitializationCompletedEvent += SdkInitializationCompletedEvent;
private void SdkInitializationCompletedEvent(){}
Step 7. Verify your integration
The ironSource SDK provides an easy way to verify that your Rewarded Video Mediation integration was completed successfully. To verify your ironSource SDK integration as well as any additional Ad Networks you have implemented, simply add this method to your project:
IronSource.Agent.validateIntegration();
For more details on the ironSource Integration Verification tool navigate to this article.
For Proguard Users Only
If you are using ProGuard with the ironSource SDK, you must add the following code to your ProGuard file (Android Studio: proguard-rules.pro or Eclipse: proguard-project.txt):
-keepclassmembers class com.ironsource.sdk.controller.IronSourceWebView$JSInterface { public *; } -keepclassmembers class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; } -keep public class com.google.android.gms.ads.** { public *; } -keep class com.ironsource.adapters.** { *; } -keep class com.ironsource.unity.androidbridge.** { *; } -dontwarn com.ironsource.mediationsdk.** -dontwarn com.ironsource.adapters.** -keepattributes JavascriptInterface -keepclassmembers class * { @android.webkit.JavascriptInterface <methods>; }
Done!
You’re now ready to start working with ironSource’s ad units and mediation tools.
What’s Next?
Once you’ve verified your integration with the Integration Helper, follow our integration guides and implement our Ad Units:
Interested in Mediation? Integrate our Rewarded Video or Interstitial Ads in your app and follow our Mediation articles.