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. 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")
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 and share 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.

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
slotIdstringID 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), the platform dispatches automatically. The platform automatically handles retries and notifications on load/display/failure.

Parameters:

ParameterTypeRequiredDescription
slotRewardedAdSlotA 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.


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
adUnitIdstringAd 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
adUnitIdstringAd 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
bannerIdstringBanner 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
bannerIdstringBanner 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)
);
});