Ad Unit

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. Implement Rewarded Video Events 

The AdTiming Unity Plugin fires several events to inform you of ad availability.

Add the following code to register to the events:

 AdTimingEvents.onRewardedVideoAvailabilityChangedEvent += RewardedVideoAvailabilityChangedEvent;
AdTimingEvents.onRewardedVideoShowedEvent += RewardedVideoAdShowedEvent;
AdTimingEvents.onRewardedVideoShowFailedEvent += RewardedVideoAdShowFailedEvent;
AdTimingEvents.onRewardedVideoStartedEvent += RewardedVideoAdStartedEvent;
AdTimingEvents.onRewardedVideoEndedEvent += RewardedVideoAdEndedEvent;
AdTimingEvents.onRewardedVideoClickedEvent += RewardedVideoAdClickedEvent;
AdTimingEvents.onRewardedVideoRewardedEvent += RewardedVideoAdRewardedEvent;
AdTimingEvents.onRewardedVideoClosedEvent += RewardedVideoAdClosedEvent;

The Plugin will notify the Listener of all possible events listed below:

void RewardedVideoAvailabilityChangedEvent(bool available) {
    Debug.Log("unity-script: I got RewardedVideoAvailabilityChangedEvent, value = " +available);
}

void RewardedVideoAdShowedEvent(string scene) {
    Debug.Log("unity-script: I got RewardedVideoAdOpenedEvent: " + scene);
}

void RewardedVideoAdRewardedEvent(string scene) {
    Debug.Log("unity-script: I got RewardedVideoAdRewardedEvent: "+scene);
}

void RewardedVideoAdClosedEvent(string scene) {
    Debug.Log("unity-script: I got RewardedVideoAdClosedEvent: " +scene);
}

void RewardedVideoAdStartedEvent(string scene) {
    Debug.Log("unity-script: I got RewardedVideoAdStartedEvent: "+scene);
}

void RewardedVideoAdEndedEvent(string scene) {
    Debug.Log("unity-script: I got RewardedVideoAdEndedEvent: "+scene);
}

void RewardedVideoAdShowFailedEvent(string error) {
    Debug.Log("unity-script: I got RewardedVideoAdShowFailedEvent, error: " + error);
}

void RewardedVideoAdClickedEvent(string scene) {
    Debug.Log("unity-script: I got RewardedVideoAdClickedEvent, name = " + scene);
}

Note: Do not assume the callbacks are always running on the main thread. Any UI interaction or updates resulting from AdTiming callbacks need to be passed to the main thread before executing.

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 RewardedVideoAvailabilityChangedEvent callback which will inform you the availability of ad inventory. 

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

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

AdTiming.Agent.isRewardedVideoReady();

Step 3. Show a RewardedVideo Ad

We strongly recommend checking the ad's availability by calling the isRewardedVideoReady 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. Implement Interstitial Events

The AdTiming Unity Plugin fires several events to inform you of ad availability.

Add the following code to register to the events:

 AdTimingEvents.onInterstitialAvailabilityChangedEvent += InterstitialAdAvailabilityChangedEvent;
AdTimingEvents.onInterstitialShowedEvent += InterstitialAdShowedEvent;
AdTimingEvents.onInterstitialShowFailedEvent += InterstitialAdShowFailedEvent;
AdTimingEvents.onInterstitialClickedEvent += InterstitialAdClickedEvent;
AdTimingEvents.onInterstitialClosedEvent += InterstitialAdClosedEvent;

The Plugin will notify the Listener of all possible events listed below:

void InterstitialAdAvailabilityChangedEvent(bool available) {
    Debug.Log("unity-script: I got InterstitialAdReadyEvent: "+available);
}

void InterstitialAdShowFailedEvent(string error) {
    Debug.Log("unity-script: I got InterstitialAdShowFailedEvent, code: " +error);
}

void InterstitialAdClickedEvent(string scene) {
    Debug.Log("unity-script: I got InterstitialAdClickedEvent: "+scene);
}

void InterstitialAdShowedEvent(string scene) {
    Debug.Log("unity-script: I got InterstitialAdOpenedEvent: "+scene);
}

void InterstitialAdClosedEvent(string scene) {
    Debug.Log("unity-script: I got InterstitialAdClosedEvent: "+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 InterstitialAdAvailabilityChangedEvent callback which will inform you the availability of ad inventory. 

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

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

AdTiming.Agent.isInterstitialReady();

Step 3. Show a Interstitial Ad

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

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

 

Banner Ad Integration for Unity Plugin 

Mobile banner ads are typically displayed at the top or bottom of the screen, and stick to the screen for the duration of the user’s session. Banner ads are a very popular ad unit for mobile apps because they are easy to implement and are a great tool for promoting advertiser awareness.
AdTiming offers 4 types of system-initiated banner ads that can be either static or animated.

Step 1. Implement Banner Events

 AdTimingEvents.onBannerLoadSuccessEvent += BannerLoadSuccessEvent;
AdTimingEvents.onBannerLoadFailedEvent += BannerLoadFailedEvent;
AdTimingEvents.onBannerClickedEvent += BannerClickedEvent;

The Plugin will notify the Listener of all possible events listed below:

void BannerLoadSuccessEvent() {
Debug.Log("unity-script: I got BannerLoadSuccessEvent ");
}

void BannerLoadFailedEvent(string error) {
Debug.Log("unity-script: I got BannerLoadFailedEvent: " + error);
}

void BannerClickedEvent() {
Debug.Log("unity-script: I got BannerClickedEvent");
}

Step 2. Load Banner Ad

To load a Banner ad, call the following method:

Load the Banner view by calling this method (in this example it’s the BANNER banner size):

AdTiming.Agent.loadBanner(PlacementId, AdSize.BANNER, BannerPositition.BOTTOM);

see table below for details about our supported standard banner sizes:

AdTimingBannerSize Description Dimensions (WxH) (points in iOS, dp in Android)
BANNER Standard Banner 320 x 50
LARGE Large Banner 320 x 90
RECTANGLE Medium Rectangular Banner 300 x 250
SMART
Smart Banner
(Adjusted for both mobile and tablet)
iOS:
If (iPhone) 320 x 50
If (iPad) 728 x 90
Android:
If (screen height ≤ 720) 320 x 50
If (screen height > 720) 728 x 90

See table below for details about our supported standard banner positions:

AdTimingBannerPosition Description
TOP Banner will be positioned at the top center of the screen
BOTTOM Banner will be positioned at the bottom center of the screen

You will receive the BannerLoadSuccessEvent and the banner will show on your app.

Hide & Display Banner

In order to provide maximum flexibility in the ad experience, you now have the ability to hide and present banners on your app.

Unlike with the Android and iOS native implementations, when banner is loaded for the first time in Unity, it will show itself, and there won’t be a need to call displayBanner().

Once you’ve loaded and served a banner, you can choose to hide this banner and re-show it at a later point in your app.

To hide the banner, call this function:

AdTiming.Agent.hideBanner(PlacementId);

 To then show this same banner again, call this function:

AdTiming.Agent.displayBanner(PlacementId);

Step 3.Destroy Banner Ad

To destroy a banner, call the following method: 

AdTiming.Agent.destroyBanner(PlacementId);

A destroyed banner can no longer be loaded. If you want to serve it again, you must initiate it again.

 

Tips:

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

AndroidLogTag: AdTimingAPI

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

Comments

0 comments

Article is closed for comments.