Menu

Basic process

For detailed examples of implementing a custom Adapter, please view: Taku Demo

1. Description of classes that need to be inherited to implement each advertising form

Developers need to inherit the class of the corresponding advertising form according to their own needs (refer to the table below) and rewrite all abstract methods, call the API of the advertising platform in the corresponding method, and call back the loading result through the class member variable mLoadListener. Call back the results of ad display, click, close and other events through the class member variable mImpressionListener

Advertising formClass name
Reward Videocom.anythink.rewardvideo.unitgroup.api.CustomRewardVideoAdapter
Interstitial adscom. anythink.interstitial.unitgroup.api.CustomInterstitialAdapter
Bannercom.anythink.banner.unitgroup.api.CustomBannerAdapter
Native advertisingcom.anythink.nativead.unitgroup.api.CustomNativeAdapter
Open screen adscom.anythink.splash.unitgroup.api .CustomSplashAdapter

See how Create a custom advertising platform in the Taku backend

If you need to use a custom Adapter to implement the Bidding function, please check: Custom advanced configuration

2. Implementation of public abstract methods and callbacks for ad loading events

2.1 Public abstract method implementation

Abstract methodParameter descriptionReturn valueFunctionWhether it must be implementedDescription
loadCustomNetworkAdContext context: Context Map serverExtra: Custom parameters configured on the server Map localExtra: This time Load incoming custom parametersvoidImplement the loading logic of ads of custom advertising platformYescontext parameter:
Corresponds to the context value passed in ATRewardVideoAd, ATInterstitial, ATNative, ATBannerView, ATSplashAd. For open-screen ads, the context type is Activity; for rewarded videos, interstitial screens, native (information flow) ads, and banner ads, the context type depends on the Context serverExtra parameter passed in to ATRewardVideoAd, ATInterstitial, ATNative, and ATBannerView. strong>:
The key-value in the Json string configured in the Taku background can be obtained through the serverExtra parameter. ThelocalExtra parameter: through ATRewardVideoAd#setLocalExtra(), ATInterstitial#setLocalExtra(), ATNative# The key-value passed in by methods such as setLocalExtra() and ATBannerView#setLocalExtra() can be obtained through the locaExtra parameter
destory-void Implement the destruction logic of the custom advertising platformYesTaku SDK will internally call this method at the appropriate time to destroy the resources of the advertising platform
getNetworkPlacementId-voidProvide the advertising slots for loading the custom advertising platform this time idisfor Taku SDK ATAdInfo object and internal related logic in the callback method
getNetworkSDKVersion-voidProvide the SDK version of this loading custom advertising platformYesUsed for the ATAdInfo object and internal related logic in the Taku SDK callback method
setUserDataConsentContext context: context boolean isConsent: whether the user is authorized isEUTraffic: whether it is the European UnionbooleanProvide user authorization status and whether it is EU The information is used to implement the GDPR setting function for the customized advertising platform. (Returns true if implemented, Taku will be used for statistical records)No(Publish Implementation of recommendations for EU regions)-
getNetworkInfoMap-MapProvide custom information for custom adsIn this method, you can create a Map and Add some additional information to this Map and return it. Developers can finally obtain this additional information by calling the ATAdInfo.getExtInfoMap() method based on the ATAdInfo object in each callback method of Taku SDK.

2.2 Callback for public advertisement loading event

Use the member variable ATCustomLoadListener in the Adapter to implement the callback of the ad loading result

Callback methodParameter descriptionDescription
onAdCacheLoadedBaseAd... baseAds: Mainly provided for native advertising callback advertising objects. Other advertising forms do not need to add parameter callbacksWhen the advertising content and materials are loaded successfully, this method is called to notify Taku SDK. Finally, Taku SDK will call back the loading success method to notify the developer
onAdLoadErrorString errorCode: Error code information String errorMsg: Detailed error informationWhen the ad loading fails, this method is called to notify Taku SDK. Finally, Taku SDK will call backLoading failed< /strong> method to notify developers (errorCode and errorMsg will be encapsulated into the AdError object in the Taku SDK callback method)

Note: When using the member variable ATCustomLoadListener, you need to perform null processing, because the Listener object may be recycled inside the aggregation SDK

3. Use and precautions of custom advertising platform Adapter

3.1 Usage process

   •Developers only need Inherit the relevant classes and rewrite the relevant methods. All methods in the custom Adapter do not need to be called by the developer. When the advertising source of the custom advertising platform is configured under the advertising space in the Taku backend, the SDK will call it at the appropriate time. Related methods in custom Adapter.

   • Developers call the load API of Taku SDK to load advertisements. Taku SDK will create a custom Adapter class through reflection according to the class name configured in the background, and call loadCustomNetworkAd() to request advertisements. , the advertisement loading result of the customized advertising platform needs to be notified to Taku SDK by calling the ATCustomLoadListener method (onAdCacheLoaded, onAdLoadError). Finally, Taku SDK will notify the developer through Taku's callback method

   •Customization The parameters (AppID, AppKey, PlacementID, etc.) required by the advertising platform when loading ads need to be configured in the form of Json strings in the advertising source of the advertising platform in the Taku backend. For example:

{
    "app_id":"2004533529842888",
    "unit_id":"VID_HD_16_9_15S_APP_INSTALL#2004533529842888_2110107055952201"
}

When Taku SDK pulls the background strategy, it will convert this Json string into a Map and pass it to the loadCustomNetworkAd(Context context, Map

   •When developers call the isAdReady API of Taku SDK, the isAdReady( of the custom Adapter will be called ) method

   •When developers call the show API of Taku SDK, the isAdReady() and show(Activity activity) methods of the custom Adapter will be called

3.3 Notes

   •When adding a custom advertising platform in the Taku background, the Adapter class name needs to be configured with the full path class name (package name + class name), otherwise the Adapter class will not be created normally when loading ads


# Change theto the developer's own adapter class name
-keep class  { *;} 
-keepclassmembers public class  { 
    public *; 
}

   •If you encounter any problems, please refer to How to test ads Find solutions

This method needs to be set before the ad is loaded

Previous
Custom Network
Next
Rewarded Video Ad
Last modified: 2025-05-30Powered by