Interstitial Ads
Interstitial ads are full-screen or full-page ads that temporarily cover an app’s interface. They’re typically shown at natural pauses or transition points—such as after completing a level in a game or when navigating between major views.
This guide shows you how to integrate interstitial ads into an your app.
Load ad
Create an instance of CTInterstitial, passing in the placementId and calling the loadAd method.
CTAdRequest adRequest = new CTAdRequest.Builder()
.setPlacementId("INTERSTITIAL_PLACEMENT_ID")// [necessary] placementId from carty publisher
.setMute(true)// [optional] does video ads mute play, sdk default value true
.build();
CTInterstitial ctInterstitial = new CTInterstitial(adRequest);
ctInterstitial.loadAd();
val adRequest = CTAdRequest.Builder()
.setPlacementId("INTERSTITIAL_PLACEMENT_ID")// [necessary] placementId from carty publisher
.setMute(true)// [optional] does video ads mute play, sdk default value true
.build()
val ctInterstitial = CTInterstitial(adRequest)
ctInterstitial.loadAd()Register Listener
It is recommended to register a listener before calling the CTInterstitial.loadAd method.
ctInterstitial.setInterstitialAdListener(new CTInterstitialAdListener() {
@Override
public void onLoaded(CTBaseAd baseAd) {
}
@Override
public void onLoadFailed(CTAdError adError) {
}
@Override
public void onShown(CTBaseAd baseAd) {
}
@Override
public void onShowFailed(CTBaseAd baseAd, CTAdError adError) {
}
@Override
public void onClicked(CTBaseAd baseAd) {
}
@Override
public void onClosed(CTBaseAd baseAd) {
}
});
ctInterstitial.setInterstitialAdListener(object : CTInterstitialAdListener {
override fun onLoaded(baseAd: CTBaseAd?) {
}
override fun onLoadFailed(adError: CTAdError?) {
}
override fun onShown(baseAd: CTBaseAd?) {
}
override fun onShowFailed(baseAd: CTBaseAd?, adError: CTAdError?) {
}
override fun onClicked(baseAd: CTBaseAd?) {
}
override fun onClosed(baseAd: CTBaseAd?) {
}
})Make sure ad ready
Before you showAd, you need to check if the ad is ready.
ctInterstitial.isReady();
ctInterstitial.isReady()Display ad
Call showAd on the CTInterstitial object that you instantiated
ctInterstitial.showAd(activity);
ctInterstitial.showAd(activity)Client-side bidding
After the ad loads successfully, you can obtain ecpm by calling CTBaseAd.getEcpm
baseAd.getEcpm();
baseAd.ecpmAfter winning the ad bid, call onC2SBiddingSuccess and pass in the second-highest bid from this bid.
ctInterstitial.onC2SBiddingSuccess("secondPrice", null);
ctInterstitial.onC2SBiddingSuccess("$secondPrice", null)After an ad is lost, onC2SBiddingFailed is called with the highest bid received in the auction.
ctInterstitial.onC2SBiddingFailed("topPrice", null);
ctInterstitial.onC2SBiddingFailed("$topPrice", null)