Skip to main content

OfferWalls

Precautions#

  • Do not execute the ad loading method in the onAdLoadFailed callback, otherwise it will cause an infinite loop.。
  • Do not directly execute the ad display method in the onAdLoaded callback. The SDK has an automatic ad refill function. If showOfferwallAd () is executed in the onAdLoaded callback, the developer will not be able to accurately control the timing of ad display.
  • Developers can refer to the offerwall.dart integration in the Demo.

Integration steps#

1、Request Ads#

Map customMap = {};
Map extraMap = TPOfferWallManager.loadOfferwallAd .createRewardVideoExtraMap(
customMap: customMap,
);
TPOfferWallManager.loadOfferwallAd("your unitId",extraMap: extraMap);

Parameter Description

unitId:The unitId created in the TradPlus backend#
  • Developers must fill in the information correctly. For example, if there are spaces before and after the unitId setting, the ad request will fail because the configuration cannot be pulled.
extraMap:Additional parameters#
  • customMap:Set Traffic Grouping Related attribute parameters
  • localParams:Set local parameters. Parameters that need to be set for individual advertising platforms.

2、Check if ads are available#

  • Developers call this method after listening to the onAdLoaded callback.
  • It is recommended that developers call this API to determine whether there are available ads before displaying ads, and then call the show method if there are ads.
  • true means there are available ads, false means there are no available ads for the time being
  • When calling offerwallAdReady and returns false, the sdk will request ads again, and the developer does not need to call the load method again.
bool isReady = await TPOfferWallManager.offerwallAdReady("unitId");

3、Display ads#

TPOfferWallManager.showOfferwallAd("unitId");

4、Other API#

These APIs return result information through corresponding callbacks

  • Set UserId It is set when the user switches accounts. UserId is bound to the subsequent points API and is set after the first successful load.
TPOfferWallManager.setUserId(unitId,"test_userid");
  • Get the current user's points balance
TPOfferWallManager.getCurrencyBalance(unitId);
  • Consumption points Use when exchanging points for items
TPOfferWallManager.spendBalance(unitId, 20);
  • Apply active reward points
TPOfferWallManager.awardBalance(unitId, 20);

5、Listening callback#

参数说明

Basic callback#

addListener() {
listener = TPOfferwallAdListener(
//Ad loading successful
onAdLoaded: (adUnitId, adInfo) {
},
// Ad loading failed
onAdLoadFailed: (adUnitId, error) {
},
//ad display
onAdImpression: (adUnitId, adInfo) {
},
//Ad display failed
onAdShowFailed: (adUnitId, adInfo, error) {
},
//Ad clicked
onAdClicked: (adUnitId, adInfo) {
},
//Ad closed
onAdClosed: (adUnitId, adInfo) {
},
//Ad source loading failed
oneLayerLoadFailed: (adUnitId, adInfo, error) {
},
)
TPOfferWallManager.setOfferwallListener(listener!);
}

other callback(optional)#

//The callback returned each time the load method is called
onAdStartLoad: (adUnitId, adInfo) {
},
//Bidding starts loading
onBiddingStart: (adUnitId, adInfo) {
},
// Bidding loading is finished
onBiddingEnd: (adUnitId, adInfo, error) {
},
//Callback triggered before each layer of waterfall initiates a request to the third-party advertising source
oneLayerStartLoad: (adUnitId, adInfo) {
},
//Configure multiple ad sources in the background, and each ad source will be called back once after loading successfully
oneLayerLoaded: (adUnitId, adInfo) {
},
//video start
onVideoPlayStart: (adUnitId, adInfo) {
},
//video end
onVideoPlayEnd: (adUnitId, adInfo) {
},
// Status of the ad slot
// isSuccess returns true, indicating that an ad source has been successfully loaded for this request
// isSuccess returns false, indicating that all ad sources under the ad slot adUnitId have failed to load for this request
onAdAllLoaded: (adUnitId, isSuccess) {
},
// New in V1.0.5
// If this callback is received after calling load, it means that the ad slot is still in the loading state and cannot trigger a new round of ad loading.
onAdIsLoading: (adUnitId) {
}

Points related callbacks(optional)#

//The current points balance is obtained successfully, amount is the points balance
currencyBalanceSuccess: (adUnitId, amount, msg) {
},
//Failed to obtain the current points balance, msg is the reason for failure
currencyBalanceFailed: (adUnitId, msg) {
},
//The currency consumption is successful, amount is the balance after consumption
spendCurrencySuccess: (adUnitId, amount, msg) {
},
//Consumption of points failed, msg is the reason for failure
spendCurrencyFailed: (adUnitId, msg) {
},
//The reward points are successfully awarded, amount is the balance after the reward
awardCurrencySuccess: (adUnitId, amount, msg) {
},
//Failed to award points, msg is the reason for failure
awardCurrencyFailed: (adUnitId, msg) {
},
//Setting the user id is completed, isSuccess is whether it is successful
setUserIdFinish: (adUnitId , isSuccess)
{
},