Unity Plugin Integration

Before you start

ironSource Mediation supports Unity version 2017.2 +, and Android Operating Systems Version 4.1 (API level 16)+.

If you’re building your app using Target SDK Level 30, make sure to use ironSource SDK Version 6.18.0+.

The download, use and access to the SDK is subject to the ironSource Mobile SDK Publisher Online Terms & 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.

New! 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 IronSource Unity Package to Your Project

Follow these steps to add the IronSource Unity Package to your project:

  1. Download Unity Plugin Version 7.0.4
  2. Make sure your Unity project is opened and import the Unity package.
  3. Double-click on the extracted file; the different files will be populated automatically as shown below:

Using the Unity Editor with the ironSource SDK The ironSource SDK is designed to work with the Android & iOS platform. The Unity Editor contains a Simulator to work with Unity code. In order to work with our plugin, you must target either an Android or iOS build to test the integration.

ironSource Mediation Demo App

The Integration Demo application demonstrate how to integrate the ironSource Mediation in your app

Download Unity Demo Application

Step 2. Unity Integration Manager – Recommended 

The ironSource Integration Manager tool is based on Google External Dependency Manager for Unity (formerly Play Services Resolver). It will enable you to download the latest versions of ironSource SDK and adapters directly from your Unity development platform. 

Prerequisites

  • Unity Developer Version 2017.2 or above
  • For iOS – Cocoapods applied
Important! If you already have Unity integration, please follow the steps here.

Manage SDK versions

Once you’ve updated your Unity package for the new SDK and Integration Manager, you’ll be able to view the ironSource sub-menu in the Unity menu bar.

To upgrade your SDK or Adapter versions:

  • Go to ironSource > 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 → Play Services Resolver → Android → Resolve

 This action should be performed after each change in the ironSource Integration Manager.

If you’re using Automatic Resolve, all updates will be performed when closing the Integration Manager window.

For Gradle Users 

Using ironSource 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: 

  1. Go to: Assets → Play Services Resolver → Android → Settings 
  2. Select “Patch mainTemplate.gradle”
  3. Save your changes, by pressing “OK”

iOS

Make sure that Cocoapods is installed:

Go to: Assets → Play Service Resolver → 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). 

    1. Select Info.plist in the Project navigator in Xcode
    2. Click the Add button (+) beside a key in the property list editor and press Return
    3. Type the key name SKAdNetworkItems
    4. Choose Array from the pop-up menu in the Type column
    5. Create a dictionary item, and below it a single sting item  
    6. Enter Key name SKAdNetworkIdentifier, and the key value:
      SU67R6K2V3.skadnetwork

    You can also add SKAdNetworkIdentifier  to your Info.plist, by using this code: 

    <array>
       <dict>
           <key>SKAdNetworkIdentifier</key>
           <string>SU67R6K2V3.skadnetwork</string>
       </dict>
    </array>
    

    For more information on editing the property list, see the Xcode documentation.

    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.ats
    • 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. Manual Integration

    As an alternative to Unity Integration Manager, you can manually integrate ironSource SDK.

    Android Manual Integration

    1. Download Android SDK Version 7.0.4
    2. Copy .aar file to /Assets/Plugins/Android
    Note:  ironSource SDK requires  google play services Basement and google play services Identifier, while other networks may also require additional google play services.

      iOS Manual Integration

      1. Download iOS SDK Version 7.0.4
      2. Unzip the file and add IronSource.framework into /Assets/Plugins/iOS

      Step 5. 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 & 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.

      1. 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);
        

        New! 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);
      2. 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);

      Step 6. 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 are 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.

      You can read this article in: