Ad API
Ad API
Since v0.2.0, rewarded video, banner, and share have been unified into a single rewarded slot
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:
| Field | Type | Description |
|---|---|---|
slotId | string | Slot identifier (specified when running) |
action | string | Action type ("REWARD_VIDEO" / "BANNER" / "SHARE") |
slotData | RewardSlotData | Data for game rendering (optional — see note below) |
RewardSlotData:
| Field | Type | Description |
|---|---|---|
imageUrl | string | Slot image URL (the game renders it directly) |
title | string | Slot title |
expiresAt | long | Expiration time (Unix ms, 0 if not set) |
slotDatamay be empty for the default rewarded video and share slots (no visual elements to render). Banner slots usually includeslotData.imageUrl. Due toJsonUtilitybehavior,slotDatamay be delivered as an empty object, so check whether fields likeimageUrlare empty before using them.
GetRewardedAdSlots(onSuccess, onFail)
Retrieves the full list of active rewarded slots.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
onSuccess | Action<GetRewardedAdSlotsResult> | - | Success callback (slots) |
onFail | Action<string> | - | Failure callback |
Success Response (GetRewardedAdSlotsResult):
| Field | Type | Description |
|---|---|---|
slots | RewardedAdSlot[] | 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
slotId | string | ✅ | ID of the slot to query |
onSuccess | Action<GetRewardedAdSlotResult> | - | Success callback (slot) |
onFail | Action<string> | - | Failure callback (includes slot not found) |
ShowRewardedAd(slot, onSuccess, onFail) (Recommended)
Runs a slot. Depending on the slot's action (video/banner/share), the platform dispatches automatically.
The platform automatically handles retries and notifications on load/display/failure.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot | RewardedAdSlot | ✅ | A slot received from GetRewardedAdSlots / GetRewardedAdSlot |
onSuccess | Action<ShowRewardedAdResult> | - | Success callback (isEnded) |
onFail | Action<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)
);
});
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.
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:
| Parameter | Type | Required | Description |
|---|---|---|---|
adUnitId | string | ✅ | Ad unit ID |
onSuccess | Action<ShowRewardedAdResult> | - | Success callback |
onFail | Action<string> | - | Failure callback |
Success Response (ShowRewardedAdResult):
| Field | Type | Description |
|---|---|---|
isEnded | bool | Whether 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
adUnitId | string | ✅ | Ad unit ID |
Instance Members (TudadaRewardedVideoAd):
| Member | Type | Description |
|---|---|---|
Load(onSuccess?, onFail?) | Method | Load ad |
Show(onSuccess?, onFail?) | Method | Show ad |
Destroy() | Method | Destroy instance |
IsLoaded | bool | Whether loading is complete |
IsDestroyed | bool | Whether destroyed |
AdUnitId | string | Ad unit ID |
OnLoad | Event | Load complete |
OnError | Event | Error occurred |
OnClose | Event | Close (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.
Banner Ad (Slot Model)
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.
bannerIdis 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/failsignals only. Reward dispatch happens inside the game.
GetAvailableBannerIds(onSuccess, onFail)
Retrieves the list of currently active banner slot IDs.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
onSuccess | Action<GetAvailableBannerIdsResult> | - | Success callback |
onFail | Action<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:
| Parameter | Type | Required | Description |
|---|---|---|---|
bannerId | string | ✅ | Banner ID (doubles as slot name) |
onSuccess | Action<GetBannerResult> | - | Success callback |
onFail | Action<string> | - | Failure callback (includes "no match") |
Success Response (GetBannerResult.banner):
| Field | Type | Description |
|---|---|---|
bannerId | string | Banner ID (doubles as slot name) |
imageUrl | string | Image URL (game renders directly) |
expiresAt | long | Expiration 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
bannerId | string | ✅ | Banner ID (doubles as slot name) |
onSuccess | Action | - | Success callback — game grants reward, etc. |
onFail | Action<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)
);
});