Mediating the Android SDK - MoPub

Introduction

Follow these steps for the Mopub configuration with the Marketplace Android SDK.
 

Step 1: Configuring Fyber Marketplace

Follow the steps below to configure Fyber Marketplace in the Mopub dashboard:

  1. Log in to your MoPub account.
  2. Click on the Networks tab.
  3. Click the Add Network button on the top right corner of the screen.
  4. In the Add network dialog, scroll down and select "Custom SDK Network"
  5. In the "Add custom SDK network" dialog, enter "Fyber Marketplace" as the network name field within the "Networks Settings" tab.

Step 2: Configuring your Ad Units

Follow these steps to configure your ad units for the Fyber Marketplace Custom Adapters:

  1. Defining the way your custom adapters work with each ad unit, can be defined either:
  • During the initial custom network definition, or
  • Later by clicking the network name, within the Networks tab.
  1. Scroll down to the unit you want to configure to work with Fyber Marketplace, and populate the Custom event class and Custom event class data, according to the required unit type.

Unit Type Custom Adapter Class
Banner com.fyber.mediation.mopub.FyberBannerForMopub
Rectangle/Medium (MRECT) com.fyber.mediation.mopub.FyberBannerForMopub
Interstitial com.fyber.mediation.mopub.FyberInterstitialForMopub
Rewarded com.fyber.mediation.mopub.FyberRewardedVideoForMopub

Note

For MRECT (Medium Ads), use the same class as the banner class, the only difference should be the written spotID. For banner placements specify a Banner SpotID, for MRECT, specify an MRECT SpotID

  1. In the Custom event class data section add the relevant Spot ID and Fyber App ID you defined for the required unit, in Fyber's revenue desk, using the following JSON syntax (case sensitive):
JSON
{ "spotID" : "Your_Fyber_spot_id" ; "appID" : "Your_Fyber_app_id" }
  1. Connecting your ad unit with a custom adapter class, adds it to all the segments containing the ad unit.

The network is then disabled and paused, by default. To complete the integration, enable the required network within the segment definition.

Step 3: Initializing the Fyber Marketplace Library

These steps walk you through how to initialize the Fyber Marketplace Library:

  1. Add Fyber's Bintray repo and dependency to your projects build.gradle file
Groovy
repositories {
    maven {
        url "https://fyber.bintray.com/marketplace"
    }
}

dependencies {
    def vampVersion = "7.7.2"
    implementation "com.fyber.vamp:mopub-custom-events-5.13:${vampVersion}"
    //don't forget to add the SDK itself - 
    implementation "com.fyber.vamp:core-sdk:${vampVersion}"
    implementation "com.fyber.vamp:mraid-kit:${vampVersion}"
    implementation "com.fyber.vamp:video-kit:${vampVersion}"
}

Source code for the custom event adapters

The source code for the above custom event adapters is available in GitHub

If you are working with a Mopub version lower than 5.5.x you must initialize the Fyber Marketplace library with your Fyber Application ID, by calling the following, before making any ad request:

Sample Code
InneractiveAdManager.initialize(this, "YOUR_FYBER_PROVIDED_APP_ID");

If you are working with Mopub 5.5.x and above:

  • Create a Mopub SdkConfiguration object
  • Add FyberAdapterConfiguration as an additional network
  • Pass it along with the Fyber Application ID using the withMediatedNetworkConfiguration method
  • Pass it on to Mopub by calling Mopub.initializeSdk
Java
Map<String, String> mediatedNetworkConfiguration = new HashMap<>();
mediatedNetworkConfiguration.put(FyberAdapterConfiguration.KEY_FYBER_APP_ID, "YOUR_FYBER_PROVIDED_APP_ID");

SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder(
"<YOUR_MOPUB_UNIT_ID>").
withAdditionalNetwork(FyberAdapterConfiguration.class.getName()).
withMediatedNetworkConfiguration(FyberAdapterConfiguration.class.getName(), mediatedNetworkConfiguration).
build();

MoPub.initializeSdk(this, sdkConfiguration, new SdkInitializationListener() {
      @Override
      public void onInitializationFinished() {
        /* MoPub SDK initialized.
      }
});

Once everything is configured properly, Mopub recognizes the Fyber custom adapter classes, when requests are issued for the related units.

You can filter your logs with the Fyber keyword, to understand Fyber's internal request flow.

Supported Mopub Versions

Fyber's Marketplace SDK version 7.6.x was configured and tested under Mopub mediation versions 5.4.x, 5.5.x, 5.6.x up to 5.13.x.

  • If you are working with Mopub 5.4.x, use 'com.fyber.vamp:mopub-custom-events-5.4:7.6.0'.
  • If you are working with Mopub 5.5.x through 5.12.x, use 'com.fyber.vamp:mopub-custom-events-5.5:7.6.0'.
  • If you are working with Mopub 5.13.x and above, use 'com.fyber.vamp:mopub-custom-events-5.13:7.6.0'. Mopub 5.13.0 has changed the custom adapter base interface, and if you upgrade your version, you must use the new adapter.