The Auto Load mode is a one-stop request maintenance solution introduced by Taku. It can intelligently determine the preloading and caching timing of the next ad at multiple nodes based on the user's usage status and ad consumption progress. On the basis of meeting the developer's operational strategy, it avoids the failure risk of real-time ad data loading and wasted impression opportunities, and reduces the negative sentiment of users caused by ads not being loaded or being loaded poorly. With the Auto Load solution, developers can avoid repeated and tedious manual intervention in the request process, achieving immediate efficiency improvements. The SDK now supports the Auto Load mode.
(1) Initialization: Call ATRewardVideoAutoAd.init(mainActivity,placementIds,listener) in the main Activity onCreate() and pass in the main Activity for Initialization. If you need to add more Auto Load Ad Placements later, please call addPlacementId(placementId) to add them.
(2) It is recommended to call entryAdScenario(placementId,scenarioId) after entering a displayable ad scenario to count the cache status of the current Ad Placement. For detailed usage of statistics, see Ad Scenarios for distinguishing data across different business scenarios.
(3) Displaying Ads: Before displaying, call isAdReady(placementId) to check if it is ready, then call **show(activity,placement,listener)** to display the ad.
(4) Server Callback: If server-side callback (S2S) support is needed to pass in userId and extraData, please set them at the following times:
Note:
① Auto Load Rewarded Video internally implements automatic loading logic, so please avoid directly executing ad display in the onRewardVideoAutoLoaded callback.
② If an Ad Placement is set for Auto Load, do not call ATRewardVideoAd (regular Rewarded Video) .load() for ad loading.
(1) When the reward for the Rewarded Video is distributed, onReward() will be called back. Developers can distribute the reward to the user in the onReward callback.
(2) Auto Load Rewarded Video supports the server callback (S2S) reward distribution mechanism, and also supports the server callback feature of each ad platform. Please refer to the Rewarded Video Server Reward (S2S) instruction.
ATRewardVideoAutoAd: Management class for Auto Load Rewarded Video Ad.
| Method | Description |
|---|---|
| void init(Context context, String\[\] placementIds, ATRewardVideoAutoLoadListener loadListener) | Initialization method for ATRewardVideoAutoAd. After Initialization, ad loading will be automatically initiated for the specified Ad Placements. context: If the following platforms are integrated: Ironsource, Kidoz, Maio, Tapjoy, context must be an Activity. placementIds: Ad Placement IDs to enable Auto Load for (null can be passed). loadListener: Ad fill callback. |
| void setLocalExtra(String placementId, Map) | Set local parameters for a specified Ad Placement. placementId: Ad Placement ID. localExtra: Local parameters. The key is obtained via ATAdConst.KEY. |
Initialization:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// It is recommended to pass the Activity when calling onCreate in the main Activity for Initialization.
ATRewardVideoAutoAd.init(MainActivity.this, new String[]{"your rv placementID1", "your rv placementID2"},autoLoadListener);
}
}
ATAdConst.KEY: Predefined Key values for LocalExtra local parameters.
| Method | Description |
|---|---|
| USER_ID | (Optional) Used for server-side reward. User's unique ID. |
| USER_CUSTOM_DATA | (Optional) Used for server-side reward. User-defined data. |
Server Callback:
// Set server callback localExtra info
private static void setPlacementIdLocalExtra(String placementId) {
String userid = "test_userid_001";
String userdata = "test_userdata_001_" + placementId + "_" + System.currentTimeMillis();
Map localMap = new HashMap<>();
localMap.put(ATAdConst.KEY.USER_ID, userid);
localMap.put(ATAdConst.KEY.USER_CUSTOM_DATA, userdata);
// Takes effect from the next ad load.
ATRewardVideoAutoAd.setLocalExtra(placementId, localMap);
}
// Setting Timing 1: Before Initialization or before adding the Ad Placement.
setPlacementIdLocalExtra("your rv placementID1");// Before Initialization, set localExtra for the specified Ad Placement.
ATRewardVideoAutoAd.init(this, new String[]{"your rv placementID1", "your rv placementID2"}, autoLoadListener);
// ATRewardVideoAutoAd.addPlacementId("placementId1");
// Setting Timing 2: After ad fill.
private static ATRewardVideoAutoLoadListener autoLoadListener = new ATRewardVideoAutoLoadListener() {
@Override
public void onRewardVideoAutoLoaded(String placementId) {
// If you need to update localExtra, set it here. Takes effect from the next load.
setPlacementIdLocalExtra(placementId);
}
@Override
public void onRewardVideoAutoLoadFail(String placementId, AdError adError) {
}
};
ATRewardVideoAutoAd:
| Method | Description |
|---|---|
| boolean isAdReady(String placementId) | Determine whether the Ad Placement has a displayable ad. placementId: The Ad Placement ID to query. |
| void show(Activity activity, String placementId, ATRewardVideoAutoEventListener eventListener) | Display the Rewarded Video Ad for this Ad Placement. activity: The Activity displaying the ad. placementId: The Ad Placement ID to display. eventListener: Rewarded Video Ad display and reward callback. See below for ATRewardVideoAutoEventListener description. |
| void show(Activity activity, String placementId, ATShowConfig showConfig, ATRewardVideoAutoEventListener eventListener) | (Added in v6.3.10) Display the Rewarded Video Ad for this Ad Placement. activity: Same parameter meaning as above. placementId: Same parameter meaning as above. showConfig: Extra parameters that can be passed during display, as follows: 1. ATShowConfig#showCustomExt(String showCustomExt): Can pass custom parameters during display. The passed parameter will be returned via ATAdInfo#getShowCustomExt(). 2. ATShowConfig#scenarioId(String scenarioId): Can pass an ad scenario, same as show(Activity activity, String placementId, String scenario, ATRewardVideoAutoEventListener eventListener). eventListener: Same parameter meaning as above. |
| void entryAdScenario(String placementId, String scenarioId) | Enter business scenario cache status statistics for the corresponding Ad Placement. placementId: Ad Placement ID. scenario: Ad display scenario. Scenario parameters can be created from the dashboard. For usage, please refer to Business Scenario Cache Status Statistics. |
Ad Display:
/*
To count scenario arrival rate, related info can be found at "https://help.takuad.com/docs/1RWLAv"
Call the “enter ad scenario” method when the ad triggering conditions are met, for example:
** If the ad scenario is to display an ad after a cleanup is finished, call it when the cleanup is finished;
* 1. First call "entryAdScenario"
* 2. Then call "isAdReady" to check if it is displayable
* 3. Finally call "show" to display
* 4. Passing the scenario ID into scenario will only result in data showing in the dashboard's scenario management.
*/
ATRewardVideoAd.entryAdScenario("your rv placementID", "your scenarioID");
// Need to check if the Ad Placement is ready.
if(ATRewardVideoAutoAd.isAdReady("your rv placementID")){
ATRewardVideoAutoAd.show(activity, "your rv placementID", "your scenarioID",autoEventListener);
}
ATRewardVideoAutoAd:
| Method | Description |
|---|---|
| checkAdStatus(String placementId) | Get the status object ATAdStatusInfo for this Ad Placement. See below for the API description of the ATAdStatusInfo object. placementId: The Ad Placement ID to query. |
| checkValidAdCaches(String placementId) | Query the ATAdInfo objects of all cached info for this Ad Placement. placementId: The Ad Placement ID to query. |
| void addPlacementId(String... placementIds) | Add Ad Placements for Auto Load. placementIds: Ad Placement IDs to enable Auto Load for. |
| void removePlacementId(String... placementIds) | Remove Ad Placements that no longer need Auto Load. placementIds: Ad Placement IDs to disable Auto Load for. |
ATAdStatusInfo: Status object of the Ad Placement.
| Method | Description |
|---|---|
| boolean isLoading() | Determine whether the current Ad Placement is currently loading an ad. |
| boolean isReady() | Determine whether the current Ad Placement has a displayable ad. Same function as ATRewardVideoAd.isAdReady(). |
| getATTopAdInfo | Get the ad cache info ATAdInfo object with the highest priority for the current Ad Placement. ATAdInfo: Ad information object, can distinguish ad platforms, mainly contains ID info of third-party Mediation platforms. See ATAdInfo Info Description |
ATRewardVideoAutoLoadListener: ATRewardVideoAutoAd ad loading event callback listener:
| Method | Description |
|---|---|
| void onRewardVideoAutoLoaded(String placementId) | Ad load success callback for the corresponding Ad Placement. placementId: The corresponding Ad Placement ID. |
| void onRewardVideoAutoLoadFail(String placementId, AdError adError) | Ad load failure callback for the corresponding Ad Placement. placementId: Ad Placement ID. adError: Ad load failure info. You can get the full error info via AdError.getFullErrorInfo(). Please refer to AdError. |
Listener Example:
private static ATRewardVideoAutoLoadListener autoLoadListener = new ATRewardVideoAutoLoadListener() {
@Override
public void onRewardVideoAutoLoaded(String placementId) {
}
@Override
public void onRewardVideoAutoLoadFail(String placementId, AdError adError) {
}
};
ATRewardVideoAutoEventListener: ATRewardVideoAutoAd ad event callback listener:
| Method | Description |
|---|---|
| void onRewardedVideoAdPlayStart(ATAdInfo atAdInfo) | Ad playback start callback (i.e., Rewarded Video impression callback). ATAdInfo: Ad information object, can distinguish ad platforms, mainly contains ID info of third-party Mediation platforms. See ATAdInfo Info Description |
| void onRewardedVideoAdPlayEnd(ATAdInfo atAdInfo) | Ad playback end callback. Same parameter meaning as above. |
| void onRewardedVideoAdPlayFailed(AdError errorCode, ATAdInfo atAdInfo) | Ad playback failure callback. atAdInfo: Same parameter meaning as above. errorCode: Ad display failure info. You can get the full error info via AdError.getFullErrorInfo(). Please refer to AdError. |
| void onReward(ATAdInfo atAdInfo) | Triggered when the reward is distributed. It is recommended for developers to distribute the reward in this callback, generally called back before onRewardedVideoAdClosed. Same parameter meaning as above. |
| void onRewardedVideoAdClosed(ATAdInfo atAdInfo) | Ad close callback. Same parameter meaning as above. |
| void onRewardedVideoAdPlayClicked(ATAdInfo atAdInfo) | Ad click. Same parameter meaning as above. |
| void onDeeplinkCallback(ATAdInfo atAdInfo, boolean isSuccess) | Deeplink callback, for Adx, OnlineApi ads. isSuccess: Whether successful. |
| void onDownloadConfirm(Context context, ATAdInfo atAdInfo, View clickView, ATNetworkConfirmInfo networkConfirmInfo) | Callback method when an app-type ad click triggers a download. atAdInfo: Same parameter meaning as above. networkConfirmInfo: Callback info provided by the third-party ad platform (Currently only GDT's GDTDownloadFirmInfo is available.) |
| void onRewardedVideoAdAgainPlayStart(ATAdInfo atAdInfo) | Pangle (China) watch-again ad playback start callback. Parameter meaning refers to onRewardedVideoAdPlayStart. |
| void onRewardedVideoAdAgainPlayEnd(ATAdInfo atAdInfo) | Pangle (China) watch-again ad playback end callback. Parameter meaning refers to onRewardedVideoAdPlayEnd. |
| void onRewardedVideoAdAgainPlayFailed(AdError errorCode, ATAdInfo atAdInfo) | Pangle (China) watch-again ad playback failure callback. Parameter meaning refers to onRewardedVideoAdPlayFailed. |
| void onRewardedVideoAdAgainPlayClicked(ATAdInfo atAdInfo) | Pangle (China) watch-again ad click callback. Parameter meaning refers to onRewardedVideoAdPlayClicked. |
| void onAgainReward(ATAdInfo atAdInfo) | Pangle (China) watch-again ad reward distribution callback. Parameter meaning refers to onReward. |
// Set server callback localExtra info
private static void setPlacementIdLocalExtra(String placementId) {
String userid = "test_userid_001";
String userdata = "test_userdata_001_" + placementId + "_" + System.currentTimeMillis();
Map localMap = new HashMap<>();
localMap.put(ATAdConst.KEY.USER_ID, userid);
localMap.put(ATAdConst.KEY.USER_CUSTOM_DATA, userdata);
// Takes effect from the next ad load.
ATRewardVideoAutoAd.setLocalExtra(placementId, localMap);
}
// Setting Timing 1: Before Initialization or before adding the Ad Placement.
setPlacementIdLocalExtra("your rv placementID1");// Before Initialization, set localExtra for the specified Ad Placement.
ATRewardVideoAutoAd.init(this, new String[]{"your rv placementID1", "your rv placementID2"}, autoLoadListener);
// ATRewardVideoAutoAd.addPlacementId("placementId1");
// Setting Timing 2: After ad fill.
private static ATRewardVideoAutoLoadListener autoLoadListener = new ATRewardVideoAutoLoadListener() {
@Override
public void onRewardVideoAutoLoaded(String placementId) {
// If you need to update localExtra, set it here. Takes effect from the next load.
setPlacementIdLocalExtra(placementId);
}
@Override
public void onRewardVideoAutoLoadFail(String placementId, AdError adError) {
}
};
/*
To count scenario arrival rate, related info can be found at "https://docs.takuad.com/#/zh-cn/android/NetworkAccess/scenario/scenario"
Call the "enter ad scenario" method when the ad triggering conditions are met, for example:
** If the ad scenario is to display an ad after a cleanup is finished, call it when the cleanup is finished;
* 1. First call "entryAdScenario"
* 2. Then call "isAdReady" to check if it is displayable
* 3. Finally call "show" to display
* 4. Passing the scenario ID into scenario will only result in data showing in the dashboard's scenario management.
*/
ATRewardVideoAd.entryAdScenario("your rv placementID1", "your scenarioID");
// Need to check if the Ad Placement is ready.
if(ATRewardVideoAutoAd.isAdReady("your rv placementID1")){
ATRewardVideoAutoAd.show(activity, "your rv placementID1", "your scenarioID",autoEventListener);
}
For detailed Rewarded Video Ad sample code, please refer to the RewardVideoAdActivity class in Demo.