Skip to main content

Native

Step 1.Prerequisites#

This document mainly introduces how to integrate Native Ads :

  • Use Android Studio 3.2 or later
  • minSdkVersion 16 or later
  • compileSdkVersion 28 or later
  • Recommended: Create your TradPlus Apps and get your AppId
  • Initialize the TradPlus SDK for Unity3DAndroid

Step 2 Import layout file#

Download the SDK compressed package, after decompression, import the res in the TradPlusSDK_Unity folder into the Assets file:

  • res:Layout files required for native ads
  • Where:res-->layout

Step 3.Integration#

...
//Create adUnitId from your App
TradPlus.LoadNativePluginsForAdUnits("AdUnitId");
//Method 1:Load an Ad and set up ads to pop up
TradPlus.CreateNative("AdUnitId",TradPlus.AdPosition.BottomCenter);
//Method 2:Load an Ad and set up ads to pop up
TradPlus.CreateNative("AdUnitId",x,y);
//Set an Scenario Id
TradPlus.NativeEntryAdScenario("AdUnitId");
//You can hide or show an ad using setVisibility when an ad is Loaded
TradPlus.ShowNative("AdUnitId",false);
//You can show an ad After hide ad
TradPlus.ShowNative("AdUnitId",true);
//Close ad
TradPlus.DestroyNative("AdUnitId");
...
// Called when the ad for the given adUnitId has loaded.
TradPlusManager.OnAdNativeLoadedEvent += OnAdNativeLoadedEvent;
// Called when the ad fails to load for the given adUnitId.
TradPlusManager.OnAdNativeFailedEvent += OnAdNativeFailedEvent;
// Called when a native ad is clicked.
TradPlusManager.OnAdNativeClickedEvent += OnAdNativeClickedEvent;
// Called when a native ad starts playing.
TradPlusManager.OnAdNativeExpandedEvent += OnAdNativeExpandedEvent;
...