Updating Your Unity Plugin

Before You Start
We support Unity version 5 and up.

Step 1.Download the IronSource Unity Package 6.5

First, go to your Project’s Assets folder and remove the Supersonic folder.

In Android: remove the Supersonic folder from Assets/Plugins/android.
In iOS: remove the Supersonic folder from Assets/Plugins/ios.

Next, add the IronSource Unity Package to your project:

  1. Download the IronSource Unity Plugin here.
  2. Make sure your Unity project is opened and unzip the Unity Package.
  3. Double-click on the extracted file; the different files will be populated automatically as shown below:
    unity-project

Important! 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.

Step 2. Update Additional Settings for Android

In the case your application doesn’t have an AndroidManifest, leave the checkbox under Assets ➣ PluginsAndroidIronSource ➣ AndroidManifest.xml checked and skip to the next step.
If you do have an AndroidManifest, please uncheck the box and follow the steps below.
  1. Update your Manifest Activities on your AndroidManifest.xmlReplace the Supersonic Manifest Activities:
    <activity
    android:name="com.supersonicads.sdk.controller.ControllerActivity"
    android:configChanges="orientation|screenSize"
    android:hardwareAccelerated="true" />
    <activity
    android:name="com.supersonicads.sdk.controller.InterstitialActivity"
    android:configChanges="orientation|screenSize"
    android:hardwareAccelerated="true"
    android:theme="@android:style/Theme.Translucent" />
    <activity
    android:name="com.supersonicads.sdk.controller.OpenUrlActivity"
    android:configChanges="orientation|screenSize"
    android:hardwareAccelerated="true"
    android:theme="@android:style/Theme.Translucent" />

    With the ironSource Manifest Activities:

    <activity
     android:name="com.ironsource.sdk.controller.ControllerActivity"
     android:configChanges="orientation|screenSize"
     android:hardwareAccelerated="true" />
    <activity
     android:name="com.ironsource.sdk.controller.InterstitialActivity"
     android:configChanges="orientation|screenSize"
     android:hardwareAccelerated="true"
     android:theme="@android:style/Theme.Translucent" />
    <activity
     android:name="com.ironsource.sdk.controller.OpenUrlActivity"
     android:configChanges="orientation|screenSize"
     android:hardwareAccelerated="true"
     android:theme="@android:style/Theme.Translucent" />

Step 3. Update SDK Methods

We’ve standardized and updated all of our methods according to tech conventions, and replaced all Supersonic mentions with ironSource. In addition, you can now initialize your preferred ad units with a single init, preferably on application launch.

You’ll need to review, remove and replace existing methods with the following:

General Methods (relevant for All Ad Units):

  • Remove the start() from your application launch.
  • New!setUserId
    The UserID is a unique identifier for each user. You can set the userID parameter, or let us generate one for you. If you’re serving the Offerwall ad unit or server-to-server callbacks to reward your users with our rewarded ad units, you must set the UserID. Common practice is to use the GAID (Google Advertiser ID).
    Note: Note: You must set the UserID parameter before the init request.
    IronSource.Agent.setUserId(YOUR_USER_ID);
  • Remove theonPause() and onResume()function and replace with the following:
    void OnApplicationPause(bool isPaused) {                 
      IronSource.Agent.onApplicationPause(isPaused);
    }

Ad Unit Initialization

Remove the init function from each ad unit:

  • Rewarded Video
     Supersonic.Agent.initRewardedVideo(appKey,uniqueUserId);
  • Offerwall
  • Supersonic.Agent.initOfferwall(appKey,uniqueUserId);
  • Interstitial
    Supersonic.Agent.initInterstitial(appKey,uniqueUserId);

Replace the init function with the following:

New! You can initialize the SDK in two ways. We recommend the first method as it will fetch the specific ad units you define.

Init the specific ad units mentioned in the adUnits parameter, preferably on app launch:

IronSource.Agent.init (YOUR_APP_KEY, IronSourceAdUnits.REWARDED_VIDEO, IronSourceAdUnits.INTERSTITIAL, IronSourceAdUnits.OFFERWALL);

Init the ad units you’ve configured on the ironSource platform SDK sync:

IronSource.Agent.init (YOUR_APP_KEY);

Ad Unit Methods

  • Rewarded Video
    Replace the Supersonic functions:
    Supersonic.Agent.showRewardedVideo();
    Supersonic.Agent.isRewardedVideoAvailable();
    Supersonic.Agent.getPlacementInfo(placementName);

    with the IronSource functions:

    IronSource.Agent.showRewardedVideo();
    IronSource.Agent.isRewardedVideoAvailable();
    IronSource.Agent.getPlacementInfo(placementName);
  • Offerwall
    Replace the Supersonic functions:
    Supersonic.Agent.showOfferwall();
    Supersonic.Agent.getOfferwallCredits();
    

    With the ironSource functions:

    IronSource.Agent.showOfferwall();
    IronSource.Agent.getOfferwallCredits();
  • Interstitial
    Replace the Supersonic functions:
    Supersonic.Agent.loadInterstitial();
    Supersonic.Agent.isInterstitialReady()
    Supersonic.Agent.showInterstitial();

    With the ironSource functions:

    IronSource.Agent.loadInterstitial();
    IronSource.Agent.isInterstitialReady()
    IronSource.Agent.showInterstitial();

Step 4. Update the Events

The ironSource Unity Plugin fires several events to inform you of ad availability. Under IronSource/Assets/Prefabs, you’ll find the IronSourceEventsPrefab. Add it to your project to receive these events.

Add the following code to register to the events:

  • Rewarded Video
    public class VideoScript : MonoBehaviour {
      void Start() 
      {
        IronSourceEvents.onRewardedVideoAdOpenedEvent += RewardedVideoAdOpenedEvent;
        IronSourceEvents.onRewardedVideoAdClosedEvent += RewardedVideoAdClosedEvent; 
        IronSourceEvents.onRewardedVideoAvailabilityChangedEvent += RewardedVideoAvailabilityChangedEvent;
        IronSourceEvents.onRewardedVideoAdStartedEvent += RewardedVideoAdStartedEvent;
        IronSourceEvents.onRewardedVideoAdEndedEvent += RewardedVideoAdEndedEvent;
        IronSourceEvents.onRewardedVideoAdRewardedEvent += RewardedVideoAdRewardedEvent; 
        IronSourceEvents.onRewardedVideoAdShowFailedEvent += RewardedVideoAdShowFailedEvent;
      } 
    }
  • Interstitial
    public class InterstitialScript : MonoBehaviour {
      void Start() 
      {
        IronSourceEvents.onInterstitialAdReadyEvent += InterstitialAdReadyEvent;
        IronSourceEvents.onInterstitialAdLoadFailedEvent += InterstitialAdLoadFailedEvent;        
        IronSourceEvents.onInterstitialAdShowSucceededEvent += InterstitialAdShowSucceededEvent; 
        IronSourceEvents.onInterstitialAdShowFailedEvent += InterstitialAdShowFailEvent; 
        IronSourceEvents.onInterstitialAdClickedEvent += InterstitialAdClickedEvent;
        IronSourceEvents.onInterstitialAdOpenedEvent += InterstitialAdOpenedEvent;
        IronSourceEvents.onInterstitialAdClosedEvent += InterstitialAdClosedEvent;
      } 
    }
  • Offerwall
    public class OfferwallScript : MonoBehaviour {
      void Start() 
      {
        IronSourceEvents.onOfferwallClosedEvent += OfferwallClosedEvent;
        IronSourceEvents.onOfferwallOpenedEvent += OfferwallOpenedEvent;
        IronSourceEvents.onOfferwallShowFailedEvent += OfferwallShowFailedEvent;
        IronSourceEvents.onOfferwallAdCreditedEvent += OfferwallAdCreditedEvent;
        IronSourceEvents.onGetOfferwallCreditsFailedEvent += GetOfferwallCreditsFailedEvent;
        IronSourceEvents.onOfferwallAvailableEvent += OfferwallAvailableEvent;
      } 
    }

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.** { *;
}

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.