For detailed examples of implementing a custom Adapter, please view: Taku Demo
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 form | Class name |
---|---|
Reward Video | com.anythink.rewardvideo.unitgroup.api.CustomRewardVideoAdapter |
Interstitial ads | com. anythink.interstitial.unitgroup.api.CustomInterstitialAdapter |
Banner | com.anythink.banner.unitgroup.api.CustomBannerAdapter |
Native advertising | com.anythink.nativead.unitgroup.api.CustomNativeAdapter |
Open screen ads | com.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
Abstract method | Parameter description | Return value | Function | Whether it must be implemented | Description |
---|---|---|---|---|---|
loadCustomNetworkAd | Context context: Context Map serverExtra: Custom parameters configured on the server Map localExtra: This time Load incoming custom parameters | void | Implement the loading logic of ads of custom advertising platform | Yes | context 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 platform | Yes | Taku SDK will internally call this method at the appropriate time to destroy the resources of the advertising platform |
getNetworkPlacementId | - | void | Provide the advertising slots for loading the custom advertising platform this time id | is | for Taku SDK ATAdInfo object and internal related logic in the callback method |
getNetworkSDKVersion | - | void | Provide the SDK version of this loading custom advertising platform | Yes | Used for the ATAdInfo object and internal related logic in the Taku SDK callback method |
setUserDataConsent | Context context: context boolean isConsent: whether the user is authorized isEUTraffic: whether it is the European Union | boolean | Provide 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 | - | Map | Provide custom information for custom ads | In 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. |
Use the member variable ATCustomLoadListener in the Adapter to implement the callback of the ad loading result
Callback method | Parameter description | Description |
---|---|---|
onAdCacheLoaded | BaseAd... baseAds: Mainly provided for native advertising callback advertising objects. Other advertising forms do not need to add parameter callbacks | When 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 |
onAdLoadError | String errorCode: Error code information String errorMsg: Detailed error information | When 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
•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
•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