Menu

Custom Network

1. Using the Custom Network Adapter

Check how to create a custom network in the TopOn dashboard

(1) You only need to inherit the relevant classes and override the corresponding methods. You don’t need to call any methods in the custom Adapter; once the custom ad source is configured in the TopOn dashboard, the SDK will call the appropriate methods in the custom Adapter at the right time.

(2) When you use the TopOn API to load ads, you need to notify the TopOn SDK of the custom network ad load results by callingATCustomLoadListener#onAdCacheLoadedandATCustomLoadListener#onAdLoadError. Eventually, you will receive a notification from the TopOn SDK via a successful load callback.

(3) After the TopOn SDK fetches the ad strategy, it will convert the configured parameters from the diagram above into a Map, and passes it to theloadCustomNetworkAd(Context context, Map serverExtra, Map localExtra). You can obtain the related parameters (AppID, AppKey, PlacementID, etc.) through the serverExtra.

 

2. Public Abstract Methods and Ad Load Event Callbacks

Implementation of Public Abstract Methods

Method Description
void getNetworkPlacementId() Provide the ad placement ID for the custom ad platform being loaded.
void getNetworkSDKVersion() Provide the SDK version of the custom ad platform being loaded.
void destory() Implement the destruction logic for the custom ad platform.
boolean setUserDataConsent(Context context, boolean isConsent, boolean isEUTraffic) (Optional)Provide information on user consent and whether the user is in the EU for the custom ad platform to implement GDPR settings. ( If implemented, return true; TopOn will use this for statistical purposes)
context: Context
isConsent: Whether the user has given consent
isEUTraffic: Whether the traffic is from the EU
Map getNetworkInfoMap() (Optional)Provide custom information for the custom ad. In this method, you can create a Map and add additional information to this Map before returning it. You can then retrieve this additional information via the ATAdInfo#getExtInfoMap() method in the TopOn SDK’s callback methods.

 

Ad Load Event Callbacks

Use the ATCustomLoadListener member variable in the Adapter to implement ad load result callbacks.

Method Description
void onAdCacheLoaded(BaseAd... baseAds) When the ad content and materials are successfully loaded, call this method to notify the TopOn SDK. Ultimately, you will receive a notification from the TopOn SDK via a successful load callback.
baseAds: Primarily used for providing ad objects to native ad callbacks; other ad formats do not require this parameter.
void onAdLoadError(String errorCode, String errorMsg) When the ad fails to load, call this method to notify the TopOn SDK. The TopOn SDK will then callback the failure method to notify the developer (errorCode and errorMsg will be encapsulated in the AdError object within the TopOn SDK callback method).
errorCode: Error code information
errorMsg: Detailed error message

⚠️Note: When using the ATCustomLoadListener member variable, ensure to handle null checks.

 

3. Using the Custom Network Adapter and Precautions

Set the Waterfall request strategy

⚠️Note:

  • When adding a custom network in the TopOn dashboard, ensure that the Adapter class name is configured with the full path (package name + class name); otherwise, the Adapter class will not be created properly during ad loading.

  • When building the release package, ensure that the Adapter class is not obfuscated. Example obfuscation rules

# Replace <AdapterClassName> with your own Adapter class name
-keep class <Adapter class name> { *;} 
-keepclassmembers public class <Adapter class name> { 
    public *; 
}
Previous
Fully automatic loading
Next
Rewarded Ads
Last modified: 2025-05-30Powered by