Before You Start
Before integrating ads unit in your app, you must:
- In the OpenMediation Publisher UI, create an account, create an app, and setup ad placement using the format ‘Interstitial Ad’. You can follow guides here.
- Follow our steps to Android SDK Integration by integrating the SDK into your project.
- If you use mediation, go to Add Mediation Networks and make sure you have added the ad network SDKs and the corresponding adapters you wish to use to your app.
New in Version 2.0.0!
For Rewarded Video, Interstitial and Cross Promote Ad, the SDK will cache ads automatically and maintain ad inventory regularly, such as pre-loading after initialization, loading after ad served and timing loading etc. You have no need to invoke load method to cache ads by yourselves anymore with version 2.x.x. The new APIs are easier to use.Interstitial
The OpenMediation Interstitial is a full-screen ad unit, usually served at natural transition points during an app's lifecycle. Both static and video interstitials are supported.
InterstitialAd Formats:
Step 1. Set the Interstitial Ad Listener
The OpenMediation SDK fires several events to inform you of Interstitial Ad activity, such as ad availability and clicked. To serve Interstitial Ad, you need to first set its listeners and process ad events. The following snippet demonstrates how to implement the InterstitialAdListener interface to receive interstitial ad events.
The SDK will notify the Listener of all possible events listed below:
import com.openmediation.sdk.interstitial.InterstitialAd;
import com.openmediation.sdk.interstitial.InterstitialAdListener;
import com.openmediation.sdk.utils.error.Error;
import com.openmediation.sdk.utils.model.Scene;
...
InterstitialAd.setAdListener(new InterstitialAdListener() {
/**
* Invoked when the interstitial ad availability status is changed.
*
* @param - available is a boolean.
* True: means the interstitial ad is available and you can
* show the video by calling InterstitialAd.showAd().
* False: means no ad are available
*/
@Override
public void onInterstitialAdAvailabilityChanged(boolean available) {
// Change the interstitial ad state in app according to param available.
}
/**
* Invoked when the Interstitial ad view has opened.
* Your activity will lose focus.
*/
@Override
public void onInterstitialAdShowed(Scene scene) {
// Do not perform heavy tasks till the ad is going to be closed.
}
/**
* Invoked when the Interstitial ad is closed.
* Your activity will regain focus.
*/
@Override
public void onInterstitialAdClosed(Scene scene) {
}
/**
* Invoked when the user clicked on the Interstitial ad.
*/
@Override
public void onInterstitialAdClicked(Scene scene) {
}
/* Invoked when the Interstitial ad has showed failed
* @param - error contains the reason for the failure:
*/
@Override
public void onInterstitialAdShowFailed(Scene scene, Error error) {
// Interstitial ad show failed
}
});
Note:
- The error parameter in onInterstitialAdShowFailed callback describes the cause of failure. Check the Error Code for more information and guidance on errors.
Step 2. Serve Interstitial Ad
Ad Availability
OpenMediation SDK automatic loads ads for you to cache the Interstitial Ads during application lifecycle if only SDK is integrated and initiated successfully. By correctly implementing the InterstitialAdListener , you will be notified about the ad availability through the onInterstitialAdAvailabilityChanged callback.
public void onInterstitialAdAvailabilityChanged(boolean available)
Another way to check if the ad is avalible is by calling the isReady function directly.
public boolean isReady()
Show Interstitial Ad
Once you receive the onInterstitialAdAvailabilityChanged callback with available=TRUE, you can invoke the showAd() method to serve a Interstitial Ad to your users.
public void showAd(String sceneName)
Note:
- Scene is a new concept being introduced for rewarded video and interstitial ads in Version 6.0. It is used to represent different ad scenarios in your app. You can use Scene-based frequency control, user rewards and data statistic etc. Go to OpenMediation UI to create multiple Scenes in Settings of Placement.
- Scene is optional,if you don't want to use it just ignore the sceneName parameter or use value "" as below.
//Use empty String as value if you don't need this functionality.
InterstitialAd.showAd("")
//Or ignore it.
InterstitialAd.showAd()
But we do not recommend this, the Availability event only occurs when the ad availability changes, true or false, which does not necessarily mean it is the right time to serve ad. And showing ads in this callback unrestricted may result in frequent or even continuous ad pop-up, which will cause confusion for users and affect the experience. You should choose when your ads will show based on your application's ad plan.
//if you would like to show ad right after it's was loaded
public void onInterstitialAdAvailabilityChanged(boolean available) {
if(available) {
InterstitialAd.showAd(sceneName)
}
}
Warning!
- Showing ads in onInterstitialAdAvailabilityChanged callback can cause unforeseen ad pop-ups. You should not do this unless it is happened only in a specific scenario and the necessary restrictions have been imposed on your invoking to showAd.
We strongly recommend checking the ad's availability by isReady method before you show Interstitial Ad to your users, as shown in the following code:
//if you would like to show ad when it's required
if (InterstitialAd.isReady()) {
InterstitialAd.showAd(sceneName);
}
Notes:
- When you have successfully completed step 2, you will have shown a Interstitial Ad to your users. If you want to serve another Interstitial Ad, you just repeat step 2 to check ad availability and show a new Interstitial Ad.
Capping and Pacing
You can use capping and pacing of scene to improve the user experience in your app by limiting the amount of ads served within a defined timeframe. You can configure capping and pacing settings for selected scene in placement setting.
Important ! To ensure you don’t show the Rewarded Video button to prompt the user to watch an ad when the placement is capped, you must call the below method to verify if a specific placement has reached its ad limit.
InterstitialAd.isSceneCapped(sceneName);
Done!
You are now all set to deliver Interstitial ads in your app!
What's Next:
Follow our integration guides to integrate additional Interstitial Ad networks on our Mediation platform or configure additional Ad Units:
Comments
Article is closed for comments.