Skip to main content

Ad API

Ad API​

Since v0.2.0, rewarded video, banner, and share have been unified into a single rewarded slot model (since v0.3.1, the reward-less interstitial ad slot runs through the same model). Query the list of active slots to render them, and when the user taps, run them with a single ShowRewardedAd(slot) call. To show only rewarded video without slots, you can still use ShowRewardedAd(adUnitId, ...) below as-is.

Unified Rewarded Slots​

Each slot has the following structure.

RewardedAdSlot:

FieldTypeDescription
slotIdstringSlot identifier (specified when running)
actionstringAction type ("REWARD_VIDEO" / "BANNER" / "SHARE" / "INTERSTITIAL")
slotDataRewardSlotDataData for game rendering (optional — see note below)

RewardSlotData:

FieldTypeDescription
imageUrlstringSlot image URL (the game renders it directly)
titlestringSlot title
expiresAtlongExpiration time (Unix ms, 0 if not set)

slotData may be empty for the default rewarded video, share, and interstitial ad slots (no visual elements to render). Banner slots usually include slotData.imageUrl. Due to JsonUtility behavior, slotData may be delivered as an empty object, so check whether fields like imageUrl are empty before using them.

Interstitial Ad Slot (INTERSTITIAL)​

Since v0.3.1, reward slots include an interstitial ad (action "INTERSTITIAL", slot ID "interstitial_ad"). It is an ad without a reward, shown following a user action (for example, tapping a button that moves to the next screen), and is looked up and run through the same API as other slots.

// The slot is only returned where interstitial ads are available — run it only after the lookup succeeds.
TudadaSDK.Instance.GetRewardedAdSlot("interstitial_ad",
onSuccess: (res) => {
TudadaSDK.Instance.ShowRewardedAd(res.slot, // pass the slot object you received
onSuccess: (r) => { }, // called after the ad is closed (isEnded is always false)
onFail: (err) => { } // called right away when no ad is ready
);
},
onFail: (err) => { }); // interstitial ads are not available in this environment
  • No reward: isEnded is always false. Do not grant a reward based on an interstitial result.
  • Run it with the slot object: calling ShowRewardedAd("interstitial_ad") with a string is interpreted as an ad unit ID and does not run the interstitial ad (depending on the environment, it fails or a rewarded ad runs instead). Always pass the slot returned by GetRewardedAdSlot / GetRewardedAdSlots.
  • Run it only where the lookup succeeds: do not run the slot where it is not returned. The interstitial ad is not shown and the behavior is not guaranteed.
  • No platform UI: unlike rewarded ads, the platform shows no loading indicator, retry, or failure notice. When no ad is ready, onFail is called right away without waiting; show your own notice if you need one.
  • Running can fail even when the slot is returned: the ad is not ready yet, another ad is in progress, the app is in the background, or the app version is not supported.
  • Do not block the game waiting for the result: onSuccess is called after the ad is closed. Handle the pause while the ad is on screen with OnHide / OnShow.
  • Call it only right after a clear user action: call it following something the user did, such as a button tap. Do not call it automatically or repeatedly at the same point.
  • More action values may be added. When branching on action, skip unknown values.
  • In the Unity Editor, GetRewardedAdSlot("interstitial_ad") returns an interstitial slot, GetRewardedAdSlots returns the default rewarded slot and the interstitial slot, and running the interstitial slot reports isEnded = false.

GetRewardedAdSlots(onSuccess, onFail)​

Retrieves the full list of active rewarded slots.

Parameters:

ParameterTypeRequiredDescription
onSuccessAction<GetRewardedAdSlotsResult>-Success callback (slots)
onFailAction<string>-Failure callback

Success Response (GetRewardedAdSlotsResult):

FieldTypeDescription
slotsRewardedAdSlot[]List of active slots
TudadaSDK.Instance.GetRewardedAdSlots(
onSuccess: (res) => {
if (res.slots.Length == 0) return;
foreach (var slot in res.slots)
Debug.Log($"{slot.slotId} / {slot.action}");
},
onFail: (err) => Debug.LogWarning("Slot query failed: " + err)
);

GetRewardedAdSlot(slotId, onSuccess, onFail)​

Retrieves a single slot by slotId. If the slot does not exist, onFail is called.

Parameters:

ParameterTypeRequiredDescription
slotIdstring✅ID of the slot to query
onSuccessAction<GetRewardedAdSlotResult>-Success callback (slot)
onFailAction<string>-Failure callback (includes slot not found)

Runs a slot. Depending on the slot's action (video/banner/share/interstitial), the platform dispatches automatically. The platform automatically handles retries and notifications on load/display/failure.

The interstitial ad slot is an exception: for the interstitial slot (interstitial_ad) the platform shows no retry or notification popup, and isEnded is always false. → Interstitial Ad Slot

Parameters:

ParameterTypeRequiredDescription
slotRewardedAdSlot✅A slot received from GetRewardedAdSlots / GetRewardedAdSlot
onSuccessAction<ShowRewardedAdResult>-Success callback (isEnded)
onFailAction<string>-Failure callback
TudadaSDK.Instance.GetRewardedAdSlots(
onSuccess: (res) => {
if (res.slots.Length == 0) return;
var slot = res.slots[0];
TudadaSDK.Instance.ShowRewardedAd(slot,
onSuccess: (r) => { if (r.isEnded) GiveReward(); }, // the game grants the reward itself
onFail: (err) => Debug.LogError("Reward run failed: " + err)
);
});
Reward delivery is the game's responsibility

If isEnded is true, the reward is due, and the game itself delivers the actual reward. On load failure the platform automatically retries, and on final failure it shows a notification popup, so you do not need to implement a separate error UI in the game (except for the interstitial ad slot).


ShowRewardedAd(adUnitId, onSuccess, onFail) (Rewarded Video)​

Displays only a rewarded video ad in a single call, without slots. The platform automatically handles ad loading, displaying, retries on failure, and error notifications.

Parameters:

ParameterTypeRequiredDescription
adUnitIdstring✅Ad unit ID
onSuccessAction<ShowRewardedAdResult>-Success callback
onFailAction<string>-Failure callback

Success Response (ShowRewardedAdResult):

FieldTypeDescription
isEndedboolWhether the ad was watched to completion
TudadaSDK.Instance.ShowRewardedAd("ad-unit-id",
onSuccess: (result) => {
if (result.isEnded)
{
Debug.Log("Reward granted!");
GiveReward();
}
},
onFail: (err) => {
Debug.LogError("Ad display failed: " + err);
}
);

Note: When ad loading fails, the platform automatically retries and displays a notification popup on final failure. You do not need to implement separate error handling UI in your game.

CreateRewardedVideoAd(adUnitId) (Legacy)​

Creates a rewarded video ad instance.

Scheduled for removal: This legacy instance API has been replaced by the unified ShowRewardedAd() and is scheduled for removal in the next version ([System.Obsolete] attribute — produces a compile warning when used).

Parameters:

ParameterTypeRequiredDescription
adUnitIdstring✅Ad unit ID

Instance Members (TudadaRewardedVideoAd):

MemberTypeDescription
Load(onSuccess?, onFail?)MethodLoad ad
Show(onSuccess?, onFail?)MethodShow ad
Destroy()MethodDestroy instance
IsLoadedboolWhether loading is complete
IsDestroyedboolWhether destroyed
AdUnitIdstringAd unit ID
OnLoadEventLoad complete
OnErrorEventError occurred
OnCloseEventClose (includes isEnded)
// Create ad instance
TudadaRewardedVideoAd rewardedAd = TudadaSDK.Instance.CreateRewardedVideoAd("ad-unit-id");

// Register events
rewardedAd.OnLoad += () => {
Debug.Log("Ad loaded");
};

rewardedAd.OnError += (err) => {
Debug.LogError("Ad error: " + err.errMsg);
};

rewardedAd.OnClose += (result) => {
if (result.isEnded)
{
// User watched to the end -> grant reward
Debug.Log("Reward granted!");
GiveReward();
}
else
{
// Closed early
Debug.Log("Ad closed early");
}

// Reload for next ad
rewardedAd.Load();
};

// Load ad
rewardedAd.Load(
onSuccess: (result) => Debug.Log("Load success"),
onFail: (err) => Debug.LogError("Load failed: " + err)
);

Showing the Ad:

// Show after loading is complete
if (rewardedAd.IsLoaded)
{
rewardedAd.Show(
onSuccess: (result) => Debug.Log("Ad displayed"),
onFail: (err) => Debug.LogError("Display failed: " + err)
);
}

Important: Call Destroy() on ad instances when they are no longer needed to clean up resources.


In v0.2.0, we recommend migrating to the unified rewarded slots (action: "BANNER"). The banner API below is kept for compatibility.

Banner ads use a slot model: the game defines slot positions on screen (e.g., "main_menu_top") and renders the ad image itself. The SDK handles only the image URL delivery and action processing; rendering, tap detection, and reward dispatch are the game's responsibility.

  • bannerId is a slot identifier doubling as the banner id.
  • When the user taps the banner, the game calls RunBannerAction(bannerId) to delegate action processing to the SDK.
  • The response carries success / fail signals only. Reward dispatch happens inside the game.

GetAvailableBannerIds(onSuccess, onFail)​

Retrieves the list of currently active banner slot IDs.

Parameters:

ParameterTypeRequiredDescription
onSuccessAction<GetAvailableBannerIdsResult>-Success callback
onFailAction<string>-Failure callback
TudadaSDK.Instance.GetAvailableBannerIds(
onSuccess: (result) => {
foreach (var slotName in result.bannerIds)
{
Debug.Log("Active slot: " + slotName);
}
},
onFail: (err) => Debug.LogWarning("Query failed: " + err)
);

GetBanner(bannerId, onSuccess, onFail)​

Fetches the banner data matched to a given slot. If no ad is matched to the slot, onFail is called.

Parameters:

ParameterTypeRequiredDescription
bannerIdstring✅Banner ID (doubles as slot name)
onSuccessAction<GetBannerResult>-Success callback
onFailAction<string>-Failure callback (includes "no match")

Success Response (GetBannerResult.banner):

FieldTypeDescription
bannerIdstringBanner ID (doubles as slot name)
imageUrlstringImage URL (game renders directly)
expiresAtlongExpiration time (Unix ms, 0 if not set)
TudadaSDK.Instance.GetBanner("main_menu_top",
onSuccess: (result) => {
// Download result.banner.imageUrl as texture and display in UI
StartCoroutine(LoadBannerTexture(result.banner.imageUrl));
},
onFail: (err) => Debug.LogWarning("No ad available for this slot: " + err)
);

RunBannerAction(bannerId, onSuccess, onFail)​

Called by the game on user banner tap. The SDK processes the action and notifies success / fail only.

Reward dispatch happens inside the game.

Parameters:

ParameterTypeRequiredDescription
bannerIdstring✅Banner ID (doubles as slot name)
onSuccessAction-Success callback — game grants reward, etc.
onFailAction<string>-Failure callback
// Called when user taps the banner
bannerButton.onClick.AddListener(() => {
TudadaSDK.Instance.RunBannerAction("main_menu_top",
onSuccess: () => GrantReward(),
onFail: (err) => Debug.LogError("Action failed: " + err)
);
});