Ad Unit

Follow

Before You Start

Before integrating ads unit in your app, you must:

  • In the AdTiming UI, create an account, create an app, and create an ad placement using the format ‘Rewarded Video’. You can follow guides here.
  • Follow our steps to Unity Plugin Integration by integrating the AdTiming Unity Plugin 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.

 

The AdTiming SDK is now included in your Unity app when you deploy it to either the Android or iOS platform. You're now ready to implement ad unit. AdTiming Unity Plugin offers two different ad formats - Video and Interstitial ad. You can choose the one that best fits your user experience needs.

 

Rewarded Video Integration for Unity Plugin

Rewarded video ads with strong interactive ability has become the mainstream form of mobile advertising industry. It is becoming increasingly common for mobile game developers to rely more on built-in ads than IAP to monetize.

The AdTiming Rewarded Video ad unit offers an engaging ad experience that rewards your users with valuable virtual content in exchange for a completed view. This user-initiated ad unit is great for gaming apps, and enhances your apps experience. This section tells you how to init, load, and show Rewarded Video Ads.

Step 1. Set Rewarded Video Ad Listener

The AdTiming SDK fires several events to inform you of Rewarded Video Ad activity. To display Rewarded Video Ads, you need to firstly implement AdTimingRewardedVideoListener() interface and pass its instance as the parameter to setRewardedVideoListener(). Then in each ad event callback method you get the corresponding ad Placement's status.

Note:

  1. Implement it before loading your ads, or the callbacks won't be triggered.
  2. Use only ONE Listener in your app. Setting it multiple times will result in the last Listener overriding the previous ones.
AdTiming.Agent.setRewardedVideoListener(new AdTimingRewardedVideoListener());
class AdTimingRewardedVideoListener : AdtRewardedVideoListener
{
/// Invoked when rewarded video is available.
public void OnRewardedVideoAvailabilityChanged(bool available)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAvailabilityChanged"+available);
}
/// Sent immediately when a rewarded video starts to play.
public void OnRewardedVideoAdStarted(string scene)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAdStarted:" + scene);
}
/// Sent immediately when a rewarded video has been showed.
public void OnRewardedVideoAdShowed(string scene)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAdShowed:" + scene);
}
/// Sent after a rewarded video has failed to play..
public void OnRewardedVideoAdShowFailed(string scene, string adTimingError)
{
Debug.LogError("UnityApp RewardedVideo OnRewardedVideoAdShowFailed:" + scene);
}
/// Sent after a rewarded video has been clicked.
public void OnRewardedVideoAdClicked(string scene)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAdClicked:" + scene);
}
/// Sent after a rewarded video has been closed.
public void OnRewardedVideoAdClosed(string scene)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAdClosed:" + scene);
}
/// Sent immediately when a rewarded video has been completed.
public void OnRewardedVideoAdEnded(string scene)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAdEnded:" + scene);
}
/// Sent after a user has been granted a reward.
public void OnRewardedVideoAdRewarded(string scene)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAdRewarded:" + scene);
}
}

 

Step 2. Check Ad Availability

After the Rewarded Ad is successfully loaded, you will be notified when the ad is available to be shown through the OnRewardedVideoAvailabilityChanged callback which will inform you the avaliability of ad inventory. 

public void OnRewardedVideoAvailabilityChanged(bool available)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAvailabilityChanged"+available);
}

Another way to check if the ad is avalible is by calling the isRewardedVideoReady function directly.

AdTiming.Agent.isRewardedVideoReady();

 

Step 3. Show a RewardedVideo Ad

We strongly recommend checking the ad's availibility by calling the isReady method before you serve Rewarded Video .

if (AdTiming.Agent.isRewardedVideoReady())
{
AdTiming.Agent.showRewardedVideo("Your Video SceneName");
}

 

InterstitialAd Integration for Unity Plugin

The AdTiming 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.

Step 1. Set InterstitialAd Listener

The AdTiming SDK fires several events to inform you of Interstitial Ad activity. To display Interstitial Ads, you need to firstly implement AdTimingInterstitialAdListener() interface and pass its instance as the parameter to setInterstitialListener(). Then in each ad event callback method you get the corresponding ad Placement's status.

Note:

  1. Implement Step 1 before loading your ads, or the callbacks won't be triggered.
  2. Use only ONE Listener in your app. Setting it multiple times will result in the last Listener overriding the previous ones.
AdTiming.Agent.setInterstitialListener(new AdTimingInterstitialListener());
class AdTimingInterstitialListener : AdtInterstitialAdListener
{
/// Invoked when interstitial video is available.
public void OnInterstitialAdAvailabilityChanged(bool available)
{
Debug.Log("UnityApp Interstitial OnInterstitialAdAvailabilityChanged: "+available);
}
/// Invoked when interstitial video has been showed.
public void OnInterstitialAdShowed(string scene)
{
Debug.Log("UnityApp Interstitial OnInterstitialAdShowed:" + scene);
}
/// Sent after a interstitial video has failed to play.
public void OnInterstitialAdShowFailed(string scene, string error)
{
Debug.LogError("UnityApp Interstitial OnInterstitialAdShowFailed:" + scene);
}
/// Sent after a interstitial video has been closed.
public void OnInterstitialAdClosed(string scene)
{
Debug.Log("UnityApp Interstitial OnInterstitialAdClosed:" + scene);
}
/// Sent after a interstitial video has been clicked.
public void OnInterstitialAdClicked(string scene)
{
Debug.Log("UnityApp Interstitial OnInterstitialAdClicked:" + scene);
}
}

 

Step 2. Check Ad Availability

After the Interstitial Ad is successfully loaded, you will be notified when the ad is available to be shown through the OnInterstitialAdAvailabilityChanged callback which will inform you the avaliability of ad inventory. 

public void OnInterstitialAdAvailabilityChanged(bool available)
{
Debug.Log("UnityApp Interstitial OnInterstitialAdAvailabilityChanged"+available);
}

Another way to check if the ad is avalible is by calling the isInterstitialReady function directly.

AdTiming.Agent.isInterstitialReady();

 

Step 3. Show a Interstitial Ad

We strongly recommend checking the ad's availibility by calling the isReady method before you serve Interstitial Ad .

if (AdTiming.Agent.isInterstitialReady())
{
AdTiming.Agent.showInterstitial(
"Your Video SceneName");
}

 Tips:

Enable local logging: (For local debugging only. Remove it before going live.)

AndroidLogTag: AdTimingAPI

AdTiming.Agent.debug(true);
Was this article helpful?
2 out of 2 found this helpful

Comments

0 comments

Article is closed for comments.