Menu

Native

1. Introduction to native advertising

Currently supported native advertising access methods are: Self-rendering information flow advertising , Template information flow advertisement, Draw information flow advertisement

Note: The above native ad styles use the same set of APIs for access, and developers can mix different native styles in the same waterfall flow

2. Description of different access methods

Access methodDescription
Self-rendering information flow advertisementDevelopers can obtain all advertising materials through the API and customize their own UI layout for access. The access method can be viewed: Information flow self-rendering ads
Template information flow adsDevelopers can obtain a fully rendered ad View through the API, and directly add it to the designated location for display. Enter the method to view: Information flow template advertisement
Draw information flow advertisementMainly suitable for scene access of full-screen page-turning video information flow, access method Can be viewed: Draw information flow advertising access

3. API description

3.1 Initialization

  • ATNative: Native ad loading class
APIParameterDescription
ATNativeContext context, String nativeTakuPlacementID, ATNativeNetworkListener listenerNative advertising initialization method, in which nativeTakuPlacementID is created through the Taku background Native advertising slotObtained
  • ATNativeNetworkListener: Advertisement loading listener
MethodParameters
onNativeAdLoaded-Ad loaded successfully
onNativeAdLoadFail(AdError error)Ad loading failed, all error information can be obtained through AdError.getFullErrorInfo(), please refer to AdError

Note: It is forbidden to execute advertisements in this callback Loading method to retry, otherwise it will cause a lot of useless requests and may cause the application to freeze

3.2 Advertisement loading

  • ATNative: Native ad loading class

3.3 Advertising display

NativeAd: Obtained through getNativeAd Ad object

APIParametersDescription
setLocalExtraMapSet local parameters
makeAdRequest-Initiate a Native ad request
getNativeAd-Get loaded ads(recommendation After obtaining, a non-null judgment must be made, because null may appear in some cases, and it will be null when there is no ad cache)

Note: After calling this method, the SDK will remove the ad cache once. If the NativeAd obtained through this method is not null, the developer must reference it by themselves for subsequent ad display, otherwise the next time this method is called, null may be returned due to no ad cache
getNativeAd(String scenario)(Deprecated since v6.3.10) Get the loaded ad(It is recommended to make a non-null judgment after obtaining it, because null may appear in some cases), and set advertising scenes for subsequent ads. Please refer to Advertising scene

Note: Same as above
getNativeAd(ATShowConfig showConfig)(v6.3.10+) Get the loaded ad(It is recommended to make a non-null judgment after obtaining it, because null may appear in some cases)

showConfig: You can pass in additional parameters during display, as follows 1.ATShowConfig#showCustomExt(String showCustomExt): You can pass in custom parameters during display, and the parameters passed in will be returned through ATAdInfo#getShowCustomExt()

2.ATShowConfig#scenarioId(String scenarioId): Advertising scenarios can be passed in, the same as getNativeAd(String scenario)
(static) entryAdScenario(String placementId, String scenarioId) Enter the current business scenario Ad space cache status statistics. The scenario refers to the advertising display scene (not required, null can be passed directly). Scene parameters can be
checkValidAdCachesQuery the ATAdInfo object of all cached information of the current ad slot
ATAdInfo: the information object of the advertisement, which can be distinguished Advertising platform, mainly includes the id information of the third-party aggregation platform See ATAdInfo information description
Method th>ParametersDescription
isNativeExpress-Whether it is a template rendering type of advertisement
renderAdContainer(ATNativeAdView view, View selfRenderView) is used for ad rendering, where the view must use the ATNativeAdView we provide
Note: When calling isNativeExpress() to return false (i.e. self-rendering), selfRenderView must pass in the developer's customized View. When returning true (template rendering), null can be passed
(ATNativeAdView view, ATNativePrepareInfo nativePrepareInfo) is used to configure ad click events, bind the close button during self-rendering, control the placement and size of the ad logo, etc., and is called after the renderAdContainer method (By default, all views are clickable, and those with advertising logos will have default placement and size)

3.4 Other API

APIParameterDescription
getAdInfo-Get the current ad cache information ATAdInfo object, which mainly includes the id information of the third-party aggregation platform. See ATAdInfo information description
clear(ATNativeAdView view)Remove the binding of the ad to the view
onResume-Called during Activity's onResume (mainly for video ads on some advertising platforms)
onPause-Called during Activity's onPause ( Mainly for video ads on some advertising platforms)
destory-Destroy the current ad object (the ad can no longer be displayed after execution)

3.5 Event callback

  • NativeAd: The advertising object obtained through getNativeAd
methodParametersDescription
setNativeEventListener(ATNativeEventListener listener)Set advertising event listening, where ATNativeEventListener is the interface class of advertising events
setDislikeCallbackListener(ATNativeDislikeListener listener)Set ad closing event callback(Currently only pangolin (Pangle), Guangdiantong and Kuaishou template ads are valid)
  • ATNativeDislikeListener:Advertising Dislike listening class
MethodParametersDescription
onAdCloseButtonClick (ATNativeAdView view, ATAdInfo atAdInfo)This method is called when the close button is clicked. If you want to remove the advertisement, the developer needs to manually call the code in this callback to remove the Native View. ATAdInfo is the information object of the advertisement, which mainly contains the id information of the third-party aggregation platformSee ATAdInfo information description
  • ATNativeEventListener: Advertising event listening interface class


methodParametersDescription
onAdImpressed(ATNativeAdView view, ATAdInfo atAdInfo)
onAdClicked(ATNativeAdView view, ATAdInfo atAdInfo)Advertising Click callback
The meaning of parameters is the same as above
onAdVideoStart(ATNativeAdView view)Ad video playback starts (only exists on some advertising platforms)
onAdVideoEnd( ATNativeAdView view)Advertising video playback ends (only exists on some advertising platforms)
onAdVideoProgress(ATNativeAdView view, int progress)

Previous
Banner Ad
Next
self-rendering ads
Last modified: 2025-05-30Powered by