Integration Yandex Mediation

Warning

Be sure to update to the latest adapter versions (Yandex Mediation). Otherwise, errors from improper adapter integration might occur, preventing the ad from being served.

Yandex Mobile Mediation is a platform that automatically selects ads from a variety of ad networks using ML algorithms, which helps you maximize your revenue. All settings are preconfigured, so you can start using it immediately without having to set up each network individually. If you've been using the Mobile Ads SDK with a single Yandex network, migrating to Yandex Mediation requires no code changes. You only need to preset the sections of third-party advertising networks' web interfaces.

Prerequisites

To prepare your app, follow the steps described in the next sections.

App requirements

  • Use Android Studio 2021 or higher.
  • Check that your app's build file uses the following values:
    • minSdkVersion 23 or higher.
    • compileSdkVersion 34 or higher.
  • Use iOS 13 or higher.
  • Use Xcode 16.4 or higher.

Set up the app in your Boost account

Register your app as a Boost app by following these steps:

  1. Log in for the Boost.
  2. Register your app in the Boost.

Integrating the Yandex Mobile Ads React Native plugin

To integrate the Yandex Mobile Ads SDK into a React Native app, use the Yandex Mobile Ads React Native plugin.

Install the Yandex Mobile Ads React Native plugin in your project. Run the following command from the project's root folder:

npm install yandex-mobile-ads

Once the plugin is added, a string with the following dependency appears in the package.json file:

"dependencies": {
    "yandex-mobile-ads": "^8.3.0"
}

Platform-specific setup

Permission to use the advertising ID

Advertising IDs are unique IDs provided by Google Play services. They're used to serve ads to users who consent to personalized ads. Users can opt out of personalized ads or reset the ID in the settings. In this case, ad networks can't use it to serve relevant ads.

You can remove the permission, if necessary. For example, you may need to do this if a policy, such as the Families Policy, doesn't allow using the ID to serve ads.

To prevent the permission from being added to your app's main manifest, add the following to the AndroidManifest.xml file:

<manifest>
   <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
</manifest>

Warning

Lack of permission and access to the ID may impact your revenue, because your app may serve less relevant ads.

COPPA setup

You can set up these policies using the AndroidManifest.file or right before initializing the SDK manually.

If you've chosen automatic initialization, add the following code to the AndroidManifest.xml file to notify the Yandex Mobile Ads SDK when the app user is a child:

<manifest>
   <application>
      <!-- Disable the use of child's personal data for app monetization.  -->
      <meta-data
         android:name="@string/yandex_mobileads_age_restricted_user"
         android:value="true" />
   </application>
</manifest>

SKAdNetwork support

Add the ad network identifiers to your app's Info.plist file. For more information, see SKAdNetwork.

Enabling mediation

Connecting individual adapters

Warning

Be sure to update to the latest adapter versions (Yandex Mobile Mediation). Otherwise, errors from improper adapter integration might occur, preventing the ad from being served.

To connect individual adapters, enable the Yandex Ads SDK, then follow the specific instructions for each adapter:

  1. Set up mediation in the Boost interface.

  2. Add a YandexMobileAds dependency to the build.gradle file of your app module:

    dependencies {
        ...
        implementation 'com.yandex.android:mobileads:x.x.x' // add supported version
    
        // Add dependencies on Yandex Mediation adapters.
    }
    
  3. Add Java 8 support to the build.gradle file of your app's Android module:

    android {
    
        compileOptions{
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }
    
  4. Add the following code to the build.gradle file of your app's Android module:

    // IronSource
    maven {
           url 'https://android-sdk.is.com/'
    }
    
    // Pangle
    maven {
           url 'https://artifact.bytedance.com/repository/pangle'
    }
    
    // Tapjoy
    maven {
           url "https://sdk.tapjoy.com/"
    }
    
    // BidMachine
    maven {
           url 'https://artifactory.bidmachine.io/bidmachine'
    }
    
    // Mintegral
    maven {
           url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea"
    }
    
    // Chartboost
    maven {
           url "https://cboost.jfrog.io/artifactory/chartboost-ads/"
    }
    
    // AppNext
    maven {
           url "https://dl.appnext.com/"
    }
    
  5. Set up permission to use an advertising ID (for apps using SDK versions older than 4.5.0).

    How to set up permission to use the ad ID

    Advertising IDs are unique IDs provided by Google Play services. They're used to serve ads to users who consent to personalized ads. Users can opt out of personalized ads or reset the ID in the settings. In this case, ad networks can't use it to serve relevant ads.

    If your app uses a Yandex Mobile Ads SDK version lower than 4.5.0, add the com.google.android.gms.permission.AD_ID permission to your app's AndroidManifest.xml file:

    <manifest>
        <application>
        <!-- For apps targeting Android 13 or higher & Yandex Mobile Ads SDK versions lower than 4.5.0 -->
            <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
        </application>
    </manifest>
    

    Starting with version 4.5.0, Yandex Mobile Ads SDK adds the com.google.android.gms.permission.AD_ID permission by default. This means you don't need to specify it in your app's main manifest. With this permission, you can use the advertising ID to serve more relevant ads from ad networks.

    You can remove the permission, if necessary. For example, you may need to do this if a policy, such as the Families Policy, doesn't allow using the ID to serve ads.

    To prevent the permission from being added to your app's main manifest, add the following to the AndroidManifest.xml file:

    <manifest>
        <application>
            <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
        </application>
    </manifest>
    

    Warning

    Lack of permission and access to the ID may impact your revenue, because your app may serve less relevant ads.

  6. Connect the required adapters separately using the appropriate packages.

To connect individual adapters, enable the Yandex Ads SDK, then follow the specific instructions for each adapter:

  1. Set up mediation in the Boost interface.

  2. Add the YandexMobileAds library to your Podfile.

    pod 'YandexMobileAds', 'x.x.x' // add supported version
    
  3. Connect the required adapters separately using the appropriate libraries.

Initializing the Yandex Mobile Ads SDK library

Successfully initializing the Yandex Mobile Ads SDK is a prerequisite for correctly integrating the library.

By default, the SDK for Android is initialized automatically on app startup. This speeds up ad loading and thus increases your monetization revenue.

By default, the SDK for iOS is initialized automatically before loading an ad. However, manual initialization can speed up the loading of the first ad, increasing your monetization revenue.

Add a MobileAds.initialize(); call to your main component's useEffect hook:

React.useEffect(() => {
    (async () => {
        // Configure the user privacy data policy before init sdk
        await MobileAds.initialize();
    })();
});

If you need to set up privacy policies for personal data in your app, make sure to do this before initializing the Yandex Mobile Ads SDK.

You can set up these policies using the AndroidManifest.file or right before initializing the SDK manually.

Learn more