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 the end user clicked on the RewardedVideo ad
*/
public void OnAdClicked(string placementId)
{
Debug.Log("RewardedVideo OnAdClicked:" + placementId);
}

/**
* Invoked when the video ad finishes plating.
*/
public void OnAdClosed(string placementId, bool isFullyWatched)
{
Debug.Log("RewardedVideo OnAdClosed:" + placementId + ",isFullyWatched:"+ isFullyWatched);
}

/** Invoked when the call to load a rewarded video has failed
* String error contains the reason for the failure.
*/
public void OnAdFailed(string placementId, string error)
{
Debug.LogError("RewardedVideo OnAdFailed:" + placementId +",Error:"+ error);
}

/**
* Invoked when rewarded videos are available.
* You can then show the video by calling videoAd.showAd().
*/
public void OnAdReady(string placementId)
{
Debug.Log("RewardedVideo OnAdReady:" + placementId);
}

/**
* Invoked when the video is completed and the user should be rewarded.
* If using server-to-server callbacks you may ignore this events and wait
* for the callback from the AdTiming server.
*/
public void OnAdRewarded(string placementId)
{
Debug.Log("RewardedVideo OnAdRewarded:" + placementId);
}
}

 

Step 2. Load Rewarded Video Ad

Invoke loadRewardedVideo method to request and cache the Rewarded Video Ad before it is going to show to users.

AdTiming.Agent.loadRewardedVideo("Your Video PlacementId");

AdTiming SDK automatic calls the loadAd for you to cache the Rewared Video Ads during SDK initialization. If you want to load a Rewarded Video Ad again after it was shown, it is strongly recommended not to load it immediately before showing. Instead request a Video Ad a short while in advance.

Notes

  • The loadAd method could be called multiple times at any time, but we do not recommend continuous requests for a short period of time. Many requests in a short period of time have no added value because the opportunities of available for inventory is unlikely at this time. 
  • If you want to serve Rewared Video Ads more than once in your application, you must show and close the currnetly cached ad before loading the next one.
  • It is a good choice to request a new Rewared Video Ads in the onAdClosed callback.

 

Step 3. Make sure Rewarded Video Ad is ready

After the Rewarded Ad is successfully loaded by calling the loadRewardedVideo in Step 2, you will be notified when the ad is ready to be shown through the onAdReady callback which will inform you the avaliability of ad inventory. 

public void OnAdReady(string placementId)
{
    Debug.Log("RewardedVideo OnAdReady:" + placementId);
}

Another way to check if the ad is avalible is by calling the isRewardedVideoReady function directly, replace "Your Video PlacementId" with your actual PlacementId.

AdTiming.Agent.isRewardedVideoReady("Your Video PlacementId");

If you have only one Placement to load in your app, or you only want to know if any Placement is ready, just call with no parameter as below:

AdTiming.Agent.isRewardedVideoReady();

 

Step 4. Show Video Ad

Once you receive the onAdReady callback, you  can invoke the showRewardedVideo method to serve a Rewarded Video Ad to your users.

Specify a Placement to show (replace "Your Video PlacementId" with your actual PlacementId):

AdTiming.Agent.showRewardedVideo("Your Video PlacementId"); 

If you have only one Placement in your app, or you don't want to specify which Placement to show, the following automatically shows the Placements that are ready:

AdTiming.Agent.showRewardedVideo();

Note:

  • Make sure the Placement is ready for show ads. We recommend checking the ad's availibility by isRewardedVideoReady method before you show Rewarded Video Ad to your users, as shown in the following code:
if (AdTiming.Agent.isRewardedVideoReady("Your Video PlacementId")) {
AdTiming.Agent.showRewardedVideo("Your Video PlacementId");
}
  • Implement with the following way if you are mediating and serving an Admob Rewarded Video Ad(Admob requires all ads related operations in the main thread) as below:
AdTiming.Agent.isRewardedVideoReady("Your Video PlacementId", new AdTimingVideoReadyListener());
class AdTimingVideoReadyListener : AdtReadyListener
{
public void IsReady(bool result)
{
if (result)
{
AdTiming.Agent.showRewardedVideo("Your Video PlacementId");
}
}
}

 

  

 

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 the end user clicked on the Interstitial Ad
*/
public void OnAdClicked(string placementId)
{
Debug.Log("Interstitial OnAdClicked:" + placementId);
}

/**
* Invoked when the Interstitial Ad finishes plating.
*/
public void OnAdClosed(string placementId)
{
Debug.Log("Interstitial OnAdClosed:" + placementId);
}

/**
* Invoked when the call to load a Interstitial Ad has failed
* String error contains the reason for the failure.
*/
public void OnAdFailed(string placementId, string error)
{
Debug.LogError("Interstitial OnAdFailed:" + placementId + ",Error:" + error);
}

/**
* Invoked when interstitial ad are available.
* You can then show the video by calling interstitialAd.showAd().
*/
public void OnAdReady(string placementId)
{
Debug.Log("Interstitial OnAdReady:" + placementId);
}
}

 

Step 2. Load InterstitialAd

Invoke loadInterstitial method to request and cache the Interstitial Ad before it is going to show to your users.

AdTiming.Agent.loadInterstitial("Your Interstitial PlacementId");

 AdTiming SDK automatic calls the loadAd for you to cache the Interstitial Ads during SDK initialization.  If you want to serve a Interstitial Ad again after it was shown, it is strongly recommended not to load it immediately before showing. Instead request a Interstitial Ad a short while in advance.

Notes

  • The loadAd method could be called multiple times at any time, but we do not recommend continuous requests for a short period of time. Many requests in a short period of time have no added value because the opportunities of available for inventory is unlikely at this time. 
  • If you want to serve Interstitial Ads more than once in your application, you must show and close the currnetly cached ad before loading the next one.
  • It is a good choice to request a new Interstitial Ads in the onAdClosed callback.

 

Step 3. Make sure Interstitial Ad is ready

After the Interstitial Ad is successfully loaded by calling the loadInterstitial in Step 2, you will be notified when the ad is ready to be shown through the onAdReady callback which will inform you the avaliability of ad inventory. 

public void OnAdReady(string placementId)
{
    Debug.Log("Interstitial OnAdReady:" + placementId);
}

Another way to check if the ad is avalible is by calling the isInterstitialReady function directly, replace "Your Video PlacementId" with your actual PlacementId.

AdTiming.Agent.isInterstitialReady("Your Video PlacementId");

If you have only one Placement to load in your app, or you only want to know if any Placement is ready, just call with no parameter as below:

AdTiming.Agent.isInterstitialReady();

 

Step 4. Show InterstitialAd

Once you receive the onAdReady callback, you  can invoke the showInterstitial method to serve a Interstitial Ad to your users.

Specify a Placement to show (replace "Your Video PlacementId" with your actual PlacementId):

AdTiming.Agent.showInterstitial("Your Interstitial PlacementId");

If you have only one Placement in your app, or you don't want to specify which Placement to show, the following automatically shows the Placements that are ready:

AdTiming.Agent.showInterstitial();

Note:

  • Make sure the Placement is ready for show ads. We recommend checking the ad's availibility by isInterstitialReady method before you show Interstitial Ad to your users, as shown in the following code:
if (AdTiming.Agent.isInterstitialReady("Your Video PlacementId")) {
AdTiming.Agent.showInterstitial("Your Video PlacementId");
}
  • Implement with the following way if you are mediating and showing an Admob Interstitial Ad (Admob requires all ads related operations in the main thread):
AdTiming.Agent.isInterstitialReady("Your Interstitial PlacementId", new AdTimingIntersititalReadyListener());
class AdTimingIntersititalReadyListener : AdtReadyListener
{
public void IsReady(bool result)
{
if (result)
{
AdTiming.Agent.showInterstitial("Your Interstitial PlacementId");
}
}
}


Tips:

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

AndroidLogTag: AdTimingAPI

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

Comments

0 comments

Article is closed for comments.