Skip to main content

NativeDraw

Step 1.Prerequisites#

This document mainly introduces how to integrate nativedraw Ads:

Step 2.Integration#

1.Create an ad#

(1)V6.X New API#

//Create adUnit Id from your App
TPNative mTPNative = new TPNative(context, "AdUnitId");

(2)V5.X Old API#

TradPlusView tradPlusView = new TradPlusView(context);
tradPlusView.setAdUnitId("AdUnitId");
  • How to create Add Unit , as shown below:

  • After add Add Unit, you can get adUnitId, as shown below:

2.Implement Event Listeners#

(1)V6.X New API#

mTPNative.setAdListener(new NativeAdListener() {
@Override
public void onAdClicked(TPAdInfo tpAdInfo) {
// Called when a nativedraw ad is clicked.
}
@Override
public void onAdLoaded(TPAdInfo tpAdInfo, TPBaseAd tpBaseAd) {
// Called when the ad for the given adUnitId has loaded.
// Get the successfully loaded data
List<View> mDrawNativeAdList = mTPNative.getDrawNativeAdList();
// Insert the successfully loaded data into your data list for display
}
@Override
public void onAdImpression(TPAdInfo tpAdInfo) {
// Called when a nativedraw ad starts playing.
}
@Override
public void onAdShowFailed(TPAdError error, TPAdInfo tpAdInfo) {
// Called when the ad fails to load for the given adUnitId.
}
@Override
public void onAdLoadFailed(TPAdError error) {
// Called when the ad fails to load for the given adUnitId.
}
@Override
public void onAdClosed(TPAdInfo tpAdInfo) {
// Called when a nativedraw ad is closed.
}
});

(2)V5.X Old API#

tradPlusView.setAdViewListener(new TradPlusView.FSAdViewListener() {
@Override
public void onAdViewLoaded(TradPlusView tradPlusView) {
// Called when the ad for the given adUnitId has loaded.
}
@Override
public void onAdViewFailed(TradPlusView tradPlusView, TradPlusErrorCode tradPlusErrorCode) {
// Called when the ad fails to load for the given adUnitId.
}
@Override
public void onAdViewClicked(TradPlusView tradPlusView) {
// Called when a nativedraw ad is clicked.
}
@Override
public void onAdViewExpanded(TradPlusView tradPlusView) {
// Called when a nativedraw ad starts playing.
}
@Override
public void onAdViewCollapsed(TradPlusView tradPlusView) {
}
@Override
public void onAdsSourceLoaded(Object o) {}
});
tradPlusView.setDrawNativeListVideoView(new IDrawNativeListVideoViewListener() {
@Override
public void updateAdView(List list) {
// Insert the successfully loaded data into your data list for display
}
});

3.Load an Ad#

(1)V6.X New API#

mTPNative.loadAd();

(2)V5.X Old API#

tradPlusView.loadAd();