Skip to main content

OfferWalls

1.Request Ads#

using TradplusSDK.Api;
// traffic group
Dictionary<string, string> customMap = {};
// local custom map, only for Android
Dictionary<string, string> localParams = {};
// local custom map, only for Android
TPOfferwallExtra extra = new TPOfferwallExtra();
extra.customMap = customMap;
extra.localParams = localParams;
// local custom map, only for Android
TradplusOfferwall.Instance().LoadOfferwallAd("Ad unit ID created on the TP platform", extra);

Parameter Description

unitId:Ad unit ID created on the TradPlus platform#
  • Developers need to fill it in correctly. For example, if there are spaces before and after the unitId setting, the ad request will fail because the configuration cannot be pulled.
TPOfferwallExtra:Extra Parameters#
  • customMap: Set Segement related attribute parameters
  • localParams:Set local parameters.Only for Android.Some ad platforms require special parameters to be set.

2.Checking for Available Ads#

  • It is recommended to call this API to check if there are available ads before displaying an ad. Only call the show method if there are ads available.
  • true indicates that there are available ads, false indicates that there are no available ads at the moment.
bool isReady = TradplusOfferwall.Instance().OfferwallAdReady("Ad unit ID created on the TP platform");

3.Entering Ad Scene (Optional)#

TradplusOfferwall.Instance().EntryOfferwallAdScenario("Ad unit ID created on the TP platform", "sceneId");

Parameter Description

sceneId :Ad Scene ID#
  • Developers can create an ad scene in TradPlus backend. The location is as follows: Application Management - Advertising Scenes.
  • When entering the advertising scene, pass in the sceneId. The sceneId must also be passed in when displaying the ad, otherwise it will affect statistics.

4.Display Ads#

// Check if there is an ad before calling show
bool isReady = TradplusOfferwall.Instance().OfferwallAdReady("Ad unit ID created on the TP platform");
if(isReady)
{
// Display Ads
TradplusOfferwall.Instance().ShowOfferwallAd("Ad unit ID created on the TP platform", "sceneId");
}

5.Others API#

When calling these APIs, you need to set up corresponding callback listeners to obtain results.

  • Set UserId

It is set when the user switches accounts. The UserId is bound to the subsequent points API and is set after the first load is successful.

// Callback Listener
TradplusOfferwall.Instance().OnOfferwallSetUserIdFinish += OnSetUserIdFinish;
void OnSetUserIdFinish(string adunit, bool isSuccess)
{
// isSuccess returns true, indicating that the user name is set successfully
// isSuccess returns false, indicating that the user name setting failed
}
// Set UserId
TradplusOfferwall.Instance().SetUserId("Ad unit ID created on the TP platform", "offerwall_userid");
  • Get the current user's points balance
// Callback Listener
TradplusOfferwall.Instance().OnCurrencyBalanceSuccess += OnCurrencyBalanceSuccess;
TradplusOfferwall.Instance().OnCurrencyBalanceFailed += OnCurrencyBalanceFailed;
void OnCurrencyBalanceSuccess(string adunit, int amount, string msg)
{
// Query successful amount: user's current number of points
}
void OnCurrencyBalanceFailed(string adunit, string msg)
{
// Query failed
}
// Set UserId
TradplusOfferwall.Instance().GetCurrencyBalance("Ad unit ID created on the TP platform");
  • Example of consumption points: Used when redeeming points for props
// Callback Listener
TradplusOfferwall.Instance().OnSpendCurrencySuccess += OnSpendCurrencySuccess;
TradplusOfferwall.Instance().OnSpendCurrencyFailed += OnSpendCurrencyFailed;
void OnSpendCurrencySuccess(string adunit, int amount, string msg)
{
// Successful deduction amount: the user’s current number of points
}
void OnSpendCurrencyFailed(string adunit, string msg)
{
// deduction failed
}
//count :number of points consumed (int)
TradplusOfferwall.Instance().SpendBalance("Ad unit ID created on the TP platform", count);
  • Apply proactively to reward points
// Callback Listener
TradplusOfferwall.Instance().OnAwardCurrencySuccess += OnAwardCurrencySuccess;
TradplusOfferwall.Instance().OnAwardCurrencyFailed += OnAwardCurrencyFailed;
void OnAwardCurrencySuccess(string adunit, int amount, string msg)
{
// Increase successful amount: the user's current number of points
}
void OnAwardCurrencyFailed(string adunit, string msg)
{
// Add failure
}
//count :Number of points awarded (int)
TPOfferWallManager.awardBalance(unitId, count);

6.Listen for Callbacks#

Parameter Description

Common Callbacks#

// Ad loaded successfully
TradplusOfferwall.Instance().OnOfferwallLoaded += OnlLoaded;
// Ad loading failed
TradplusOfferwall.Instance().OnOfferwallLoadFailed += OnLoadFailed;
// Ad displayed successfully
TradplusOfferwall.Instance().OnOfferwallImpression += OnImpression;
// Ad display failed
TradplusOfferwall.Instance().OnOfferwallShowFailed += OnShowFailed;
// Ad clicked
TradplusOfferwall.Instance().OnOfferwallClicked += OnClicked;
// Ad closed
TradplusOfferwall.Instance().OnOfferwallClosed += OnClosed;
// Callback when each layer of waterfall fails to load
TradplusOfferwall.Instance().OnOfferwallOneLayerLoadFailed += OnOneLayerLoadFailed;
void OnlLoaded(string adunit, Dictionary<string, object> adInfo)
{
// Ad loaded successfully
}
void OnLoadFailed(string adunit, Dictionary<string, object> error)
{
// Ad loading failed
}
void OnImpression(string adunit, Dictionary<string, object> adInfo)
{
// Ad display successful
}
void OnShowFailed(string adunit, Dictionary<string, object> adInfo, Dictionary<string, object> error)
{
// Ad display failed
}
void OnClicked(string adunit, Dictionary<string, object> adInfo)
{
// Ad click
}
void OnClosed(string adunit, Dictionary<string, object> adInfo)
{
// Ad close
}
void OnOneLayerLoadFailed(string adunit, Dictionary<string, object> adInfo, Dictionary<string, object> error)
{
// Callback when each layer of waterfall fails to load
}

Ad Source Dimension Callback Listener (Optional)#

// Callback returned each time the load method is called
TradplusOfferwall.Instance().OnOfferwallStartLoad += OnStartLoad;
// Called when each layer of the waterfall starts loading
TradplusOfferwall.Instance().OnOfferwallOneLayerStartLoad += OnOneLayerStartLoad;
// Called when each layer of the waterfall has successfully loaded
TradplusOfferwall.Instance().OnOfferwallOneLayerLoaded += OnOneLayerLoaded;
// Loading process completed
TradplusOfferwall.Instance().OnOfferwallAllLoaded += OnAllLoaded;
// If this callback is received after calling load, it means that the ad space is still being loaded and cannot trigger a new round of ad loading. Added in V1.0.5
TradplusOfferwall.Instance().OnOfferwallIsLoading += OnAdIsLoading;
void OnStartLoad(string adunit, Dictionary<string, object> adInfo)
{
// The callback returned each time the load method is called
}
void onAdIsLoading(string unitId)
{
// If this callback is received after calling load, it means that the ad space is still being loaded and cannot trigger a new round of ad loading. Added in V1.0.5
}
void OnOneLayerStartLoad(string adunit, Dictionary<string, object> adInfo)
{
// Called when each layer of the waterfall starts loading
}
void OnOneLayerLoaded(string adunit, Dictionary<string, object> adInfo)
{
// Called when each layer of the waterfall has successfully loaded
}
void OnAllLoaded(string adunit, bool isSuccess)
{
// Loading process completed
// isSuccess is true if at least one ad source has successfully loaded ads for the ad unit ID
// isSuccess is false if all ad sources have failed to load ads for the ad unit ID
}