Mopub Adapter for Android SDK

MoPub_Logo.png

 This document describes the procedure for serving StartApp Ads in your application using MoPub as the mediation network

NOTES:
  • The code samples in this document can be copy/pasted into your source code
  • Feel free to take a look at our Sample Project to help you during the integration process
  • If you have any questions, contact us via support@startapp.com

 

Assumptions:

MoPub is set as your mediation network

The following manual assumes that you are already familiar with the MoPub Mediation Network and have already integrated the MoPub Android SDK into your application with at least one Ad Unit. 
Otherwise, please start by reading the following articles for a walk-through explanation of what mediation is, how to use the MoPub Mediation UI, and instructions on how to add MoPub mediation code into your app.

You application is defined in your StartApp Account

At this point we assume that you have already added your application to your StartApp account, in case you haven't, please follow the next steps:

  1. Login into your StartApp Publisher's account
  2. Add your application and get its App ID
  3. Download the StartApp In-App SDK

For any questions or difficulties during this process, please contact us via support@startapp.com

You have integrated the StartApp In-App SDK V.4.5.0 and up, as well as your desired Ad Formats.

Before you can integrate the mediation adapter, you need to make sure you have integrated the StartApp SDK V.4.5.0 or up, as well as the Ad Formats you wish to monetize. 

In case you haven't, please start from the steps described on the following SDK integration guide

NOTES:
  • Note that this MoPub adapter is only compatible from StartApp SDK V.4.5.0

 

Step 1, Integrating the MoPub Mediation Adapter

You can add the MoPub adapter via Gradle jCenter dependency 

dependencies{ 
implementation 'com.startapp:inapp-sdk:4.+'
implementation 'com.startapp:mopub-mediation:3.+'
}


Another option to integrate the Adapter is through .java files:

StartApps MoPub Adapter is available on open source from GitHub.

  • Please use only one of the options mentioned above 

Step 2, SDK Initialization

There are two options for Initializing the StartApp SDK while using MoPub as mediation, please select only one: 

  1. Option 1: Preferred and more robust way is passing your startapp appId to the MoPub custom event interface the optional parameter - 'startappAppId'
    Example:
    {startappAppId:'your_app_id_from_portal'}
  2. Option 2: Initialize StartApp sdk from the code. For this case just add a few lines which include your appId to the MoPub's SdkConfiguration object
    Example:
    final SdkConfiguration configuration = new SdkConfiguration.Builder(getString(R.string.mopubId))
    .withAdditionalNetwork(StartappConfig.class.getName())
    .withMediatedNetworkConfiguration(StartappConfig.class.getName(), Collections.singletonMap("startappAppId", "your_app_id_from_portal"))
    .build();

 

 

Step 3, Configure MoPub Mediation Settings

  • Login into your MoPub account
  • Navigate to "Orders" tab and click "Create Order"
    CreateOrder.png
    OrderCreation.png
  • After Saving Create your Line Item and set it up to Type: "Network Line Item"


    LineItem_Stup.png

In this section, based on the Ad Units you wish StartApp to monetize add the relevant information (you would need to create one Line Item per each Ad Unit):

Under the "CUSTOM EVENT CLASS" section:

  • All Ad Formats: com.mopub.mobileads.StartappAdapter
  • Native Ads: com.mopub.nativeads.StartappNative

 Under the "Custom event data" section:

 Interstitial: 

{startappAppId:'your_app_id_from_portal', adTag:'interstitialTagFromServer', interstitialMode:'OVERLAY', minCPM:0.02, muteVideo:false} 
}

 Banner &  Medium Rectangle (300x250): 

{startappAppId:'your_app_id_from_portal', adTag:'bannerTagFromServer', minCPM:0.02, is3DBanner:false} 
}

Native: 

{startappAppId:'your_app_id_from_portal', adTag:'nativeTagFromServer', minCPM:0.02, nativeImageSize:'SIZE150X150', nativeSecondaryImageSize:'SIZE340X340'} 
}

Rewarded

{startappAppId:'your_app_id_from_portal', adTag:'rewardedTagFromServer', minCPM:0.02, muteVideo:false} 
}

Step 4, MoPub Ad Unit Advanced Configuration via Code 

There are several parameters for each Ad Unit which can be configured from the MoPub portal as described on section 3 or though code as described on this section.

All parameters mentioned below are optional and should be set based on your monetization strategy and criteria.

NOTES:
  • Everything defined from the MoPub Portal will override the parallel configuration made through the code.
  • All configurable parameters must be set in Json format and under the relevant custom event class, note that you can choose to configure non to any of the available parameters.

Interstitial Settings

final Map<String, Object> extras = new StartappExtras.Builder()
	.setAdTag("interstitialTagFromAdRequest")
	.setInterstitialMode(StartappExtras.Mode.OFFERWALL)
	.muteVideo()
	.setMinCPM(0.01)
	.toMap();

interstitial.setLocalExtras(extras);
interstitial.load(); 
}

Banner Settings

final Map<String, Object> extras = new StartappExtras.Builder()
	.setAdTag("bannerTagFromAdRequest")
	.enable3DBanner()
	.setMinCPM(0.01)
	.toMap();

bannerView.setLocalExtras(extras);
bannerView.loadAd(); 
}

Rewarded Video Settings

final Map<String, Object> extras = new StartappExtras.Builder()
	.setAdTag("nativeTagFromAdRequest")
   	.setMinCPM(0.01)
   	.setNativeImageSize(StartappExtras.Size.SIZE72X72)
   	.setNativeSecondaryImageSize(StartappExtras.Size.SIZE150X150)
   	.toMap();

moPubNative.setLocalExtras(extras);
moPubNative.makeRequest(requestParameters); 
}

Netive Ad Settings

final Map<String, Object> extras = new StartappExtras.Builder()
    .setAdTag("nativeTagFromAdRequest")
    .setMinCPM(0.01)
    .setNativeImageSize(StartappExtras.Size.SIZE72X72)
    .setNativeSecondaryImageSize(StartappExtras.Size.SIZE150X150)
    .toMap();

moPubNative.setLocalExtras(extras);
moPubNative.makeRequest(requestParameters); 
}

Step 6, Testing Your Application

Congratulation - that's it! You may now run your app and see StartApp ads in action.

Was this article helpful?
0 out of 0 found this helpful