React Native Plugin Integration

Before you start

Our React Native plugin is supported from the native SDK versions 7.2.4.1 for Android and 7.2.4 for  iOS.

The plugin supports both JavaScript and TypeScript. The type declarations are included in the npm package.

Support React Native 0.66+.

iOS version support is defined per network.  ironSource ads and LevelPlay mediation supports iOS versions 12+,  XCode version 14.3.1+.

Android operating systems version 5.0 (API level 21)+.ֿ

Step 1. Add the ironSource Mediation plugin to your project

NPM Integration

There are 2 options for adding the ironSource React Native plugin to your project, using npm:

  1. Run the npm CLI command
    npm install ironsource-mediation

  2. Update package.json file
    Add the ironsource-mediation definition to your package.json file:
    "dependencies": {
        "ironsource-mediation": "3.0.0"
    }

  3. Add Ad Quality SDKAndroid:
    dependencies { implementation 'com.ironsource:adqualitysdk:7.22.0 }

    iOS:

    pod 'IronSourceAdQualitySDK','7.22.0'

Manual Integration

  1. Download React Native Plugin Version
  2. Add the ironsource-mediation definition to your package.json file:
  "dependencies": {
    "ironsource-mediation": "Path/To/Local/Directory"
  },

ironSource LevelPlay demo app

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

Download React Native 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

  1. 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.3.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.

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

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

    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 just integrated the ironSource SDK in your app. 
    You are now ready to start working with 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.