Table of Contents
Getting Started
This document details the process of integrating YouAppi MoPub Adapter with your Android app.
If you have any question you can email us at support@youappi.com
The basic steps of integration are:
- Add our dependencies to your project.
- Add YouAppi to your MoPub console.
- Load an ad.
- Show an ad.
Requirements:
Minimum API level: 16, Android 4.1
Integration
- Add the following repository to your project build.gradle:
repositories {
maven { url 'http://repository.youappi.com/repository/release-ext' }
maven { url "https://maven.google.com" }
}
- Add the following dependency to your module build.gradle:
dependencies {
implementation 'com.youappi.sdk:youappi-sdk-android-mopub-moat:4.3.8+0_2_1'
implementation('com.mopub:mopub-sdk:5.1.0@aar') {
transitive = true
}
}
Proguard
If you use proguard in your application you should add these entries to your proguard file:
-keep class com.youappi.sdk.mediation.mopub.YouAPPiInterstitialAd{*;}
-keep class com.youappi.sdk.mediation.mopub.YouAPPiInterstitialVideo{*;}
-keep class com.youappi.sdk.mediation.mopub.YouAPPiRewardedVideo{*;}
Create YouAppi custom network
- On MoPub platform on Networks tab, add a new custom network for YouAppi:
- On the popup that opens choose to add a Custom Native Network.
- Name your new network (YouAppi might be a good name) and fill other relevant details.
Setup MoPub for YouAppi Ad units
Create rewarded video ad unit
- On your MoPub account, press Apps tab.
- Select your Android app for which you would like or create the new ad unit or create a new Android app.On your app screen press “New ad unit” button:
- On your app screen press “New ad unit” button:
- Name your add unit, select “Format” Rewarded Video and press Save
Create Interstitial Video or Interstitial Ad units
- Assuming you already created an Android app, press Apps tab and from the apps list choose your Android app.
- Press New ad unit button to define a new ad unit for either Interstitial Video or Interstitial Ad.
- Name you ad unit, choose relevant device and on format choose Fullscreen:
Setup Ad Unit on network
- Choose Networks and select your YouAppi custom network.
- On network details screen choose Edit Network.
- On Set Up Your Inventory section, connect between your Android app ad unit and YouAppi by setting the proper Custom Event Class.
- For each ad unit type there is a different custom event class:
- Rewarded Video: com.youappi.sdk.mediation.mopub.YouAppiRewardedVideo
- Interstitial Video: com.youappi.sdk.mediation.mopub.YouAppiInterstitialVideo
- Interstitial Ad: com.youappi.sdk.mediation.mopub.YouAppiInterstitialAd
- On the custom event class data the following information should be supplied:
- accessToken – the access token of the partner received from YouAppi.
- adUnitId – an arbitrary id chosen the by app developer to identify the ad unit id. It should be by only numbers, letters and underscores.
- Here is an example of how the custom event class data should look like:
{ "accessToken": "821cfa77-3127-42b5-9e6b-0afcecf77c67", "adUnitId": "testRewardedVideoAdUnitId" }
Enable YouAppi ad unit to run on YouAppi custom network
- Press Segments tab and choose your desired segment.
- Under your Android app find your desired ad unit and YouAppi custom network.
- Switch your network to running by pressing the button under Enabled column:
Use MoPub SDK to show YouAppi ad units
Rewarded Video
Load
SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder("<Replace with MoPub Rewarded Video Ad Unit ID>").build();
MoPub.initializeSdk(this, sdkConfiguration, this);
MoPubRewardedVideos.loadRewardedVideo("<Replace with MoPub Rewarded Video Ad Unit ID>");
Show
MoPubRewardedVideos.showRewardedVideo("<Replace with MoPub Rewarded Video Ad Unit ID>");
Interstitial Video
Load
MoPubInterstitial moPubInterstitialVideo = new MoPubInterstitial(this, "<Replace with MoPub Interstitial Video Ad Unit ID>");
moPubInterstitialVideo.load();
Show
moPubInterstitialVideo.show();
Interstitial Ad
Load
MoPubInterstitial moPubInterstitialAd = new MoPubInterstitial(this, "<Replace with MoPub Interstitial Ad Unit ID>");
moPubInterstitialAd.load();
Show
moPubInterstitialAd.show();
Load and Show best practices
- Make sure to init the SDK as soon as the app starts. It might take few seconds to complete the init process.
- Make sure to load the ad about 30 seconds before you want to show it since it takes time for the ad and assets to be prepared.
- Make sure to show an ad as close as possible to its load, in order to have a better fill rate and relevant ads.
- Make sure not to wait too long before showing an ad, since the ad will be expired 5 hours after being called for. In other words, “show” must be performed no more than 5 hours after the “load”.
- Use ad event listeners in order to be notified when an ad is ready to be shown.
- Use ad event listeners to handle load and show.
- Loading an ad too many times without showing it might cause YouAppi servers to block the SDK from requests.