Flutter Plugin Integration

Before you start

Flutter plugin is supported from SDK version 7.2.1.2 for Android & iOS.

Support Flutter 3.0.0+.

Step 1. Add the ironSource Mediation plugin to your project

Pub.dev Integration

There are 2 options of adding the ironSource Flutter plugin to your project, using the pub.dev interface:

  1. Run the Flutter CLI command
    flutter pub get ironsource_mediation

  2. Update pubspec.yaml file
    Add the ironsource_mediation definition to your pubspec.yaml file:
    dependencies:
      flutter:
        sdk: flutter
      ironsource_mediation: ^3.0.0

  3. Add Ad Quality SDK
    Android:
    dependencies {
        implementation 'com.ironsource:adqualitysdk:7.22.2'
    }

    iOS:
    pod 'IronSourceAdQualitySDK','7.22.2'
    

Manual Integration

Download Flutter Plugin Version

ironSource LevelPlay demo app

The Integration Demo application demonstrates how to integrate ironSource LevelPlay in your app

Download Flutter Demo Application

Step 2. Additional settings for iOS

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:

<key>SKAdNetworkItems</key>
<array>
   <dict>
      <key>SKAdNetworkIdentifier</key>
      <string>su67r6k2v3.skadnetwork</string>
   </dict>
</array>

SKAdNetork IDs Manager

Use ironSource SKAdNetwork IDs Manager to easily create code snippet to support ironSource network and mediated network IDs. 

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.

  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 NSAdvertisingAttributionReportEndpoint
  4. Choose String from the pop-up menu in the Type column
  5. 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.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 3. Additional setup for Android

Play Services Dependencies

Add Play Services Dependencies to your app level build.gradle as follows:

dependencies {
   implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
   implementation 'com.google.android.gms:play-services-basement:18.0.0'
   implementation 'com.google.android.gms:play-services-appset:16.0.2'
}

Android 12 Support

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.

Replace Label on AndroidManifest.xml

To prevent the label-related error on AndroidManifest, do the following:

  • Add ‘xmls:tools’ to AndroidManifest.xml of your project
  • Add ‘tools:replace=”android:label”’ to the ‘application’ tag

Step 4. Initialize ironSource SDK

    To initialize the ironSource SDK, follow these steps:

    1. Implement callbacks for initialization success and failure.
    2. Define the list of ad formats that require support from legacy ironSource API. This should include REWARDED. 
    3. Call the LevelPlay init API using the appKey, ad formats, and user ID if relevant.
    User ID

    Add the user ID as part of the initialization API if you’re using server-to-server callbacks to reward your users, or using Ad Quality user journey

    class MyLevelPlayInitListener implements LevelPlayInitListener {
      @override
      void onInitFailed(LevelPlayInitError error) {
    	// Provided when init is failed
      }
      @override
      void onInitSuccess(LevelPlayConfiguration configuration) {
    	// Provided when init is successfully executed
      }
    }
    // Init the SDK when implementing the Multiple Ad Units Interstitial and Banner APIs, and Rewarded using legacy APIs  
    List<AdFormat> legacyAdFormats = [AdFormat.REWARDED];
    LevelPlayInitRequest initRequest = LevelPlayInitRequest.builder([APP_KEY])
                    .withLegacyAdFormats(legacyAdFormats)
                    .withUserId("userId")
                    .build();
    LevelPlay.init(initRequest, MyLevelPlayInitListener());
    

    LevelPlay Init Listeners

    • onInitSuccess – will be triggered when the init was completed successfully, and ads can be loaded.
    • onInitFailed – the configuration was not received successfully, and ads cannot be loaded. It is recommended to try and init the ironSource SDK later.
    Important!
    • All APIs called before the init API were not changed and should have remained as is, in terms of functionality and syntax. This includes advanced settings, regulations settings or other APIs related to specific ad format  
    • If initialization fails, you can try and initialize the SDK again. Only after a successful initialization process will you be able to load ads.

    Step 5. Verify your integration

    The ironSource SDK provides an easy way to verify that your 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.validateIntegration();

    For more details on the ironSource Integration Verification tool navigate to this article.

    Adapters Debug

    Call the following API to enable debug logs of mediated network adapters & SDKs:

    IronSource.setAdaptersDebug(true);

    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?

    1. Follow our integration guides to implement ad formats
    2. Interested in Mediation? Integrate our Rewarded Video, Interstitial or Banner Ads in your app and follow our Mediation articles.
    3. Verify your integration with our Integration Test Suite.