Menu

Unity SDK initialization

1. API Description

APIParameterDescription
initSDKstring appid, string appkeyInitialize the SDK, where appId and appKey need to be obtained after the application is created in the TopOn background.
How to get the App Key?
setLogDebugbool isDebugWhether to enable the Debug log of the SDK, It is strongly recommended to enable it during the testing phase to facilitate troubleshooting
setChannelstring channelSet channel information, which is used to distinguish advertising data in the TopOn backend. Only characters are allowed to be set: [A-Za-z0-9_]

Note: If the initCustomMap() method is used, this method must be called after the initCustomMap() method
setSubChannelstring subChannelSet sub-channel information, only allowed to set character rules: [ A-Za-z0-9_]

Note: If you use initCustomMap( ) method, this method must be called after the initCustomMap() method
initCustomMapDictionary<string, string> customMapCustomized key-value, which can be used to match the advertising list information issued by the backend in the App dimension
Custom rules of the App It is a global setting and is valid for all Placements.
Developers can set corresponding custom rules in the traffic grouping in the TopOn background. For details, please refer to Instructions for using traffic grouping

Note: Calling this method will clear setChannel() , the information set by the setSubChannel() method. If you have set this information, please reset it after calling this method
setCustomDataForPlacementIDDictionary<string, string> customData, string placementIDCustomized key-value, which can be used to match the ad list information issued by the backend in the ad space dimension
Only valid for the current Placement, you can customize it in App Rules Add Placement-specific custom rules.
Developers can set corresponding custom rules in the traffic grouping in the TopOn backend. For details, please refer to Instructions for using traffic grouping
getUserLocationDetermine whether the current network is in the EU
getGDPRLevel -Get the current reporting level of privacy data
showGDPRAuth-Show GDPR authorization page
showGDPRConsentDialogShow GDPR authorization page with Google UMP

2. Sample code

Your App needs to formulate a "Privacy Policy" and display the "Privacy Policy" when the user starts the App for the first time. Privacy Policy" and obtain user consent. For the "Privacy Policy" formulated by the App, please refer to "Privacy Compliance Guide" Please ensure that the user agrees to the App's "Privacy Policy" before initializing TopOn SDK


You can initialize AnyThinkSDK through the following code :

//(Optional configuration) Set custom Map information to match the list of advertisers configured in the background (App latitude)
//Note: Calling this method will clear the information set by the setChannel() and setSubChannel() methods. If this information has been set, please reset it after calling this method.
ATSDKAPI.initCustomMap(new Dictionary<string, string> { { "unity3d_data", "test_data" } }); 

//(Optional configuration) Set custom Map information to match the list of advertisers configured in the background (Placement latitude)
ATSDKAPI.setCustomDataForPlacementID(new Dictionary<string, string> { { "unity3d_data_pl", "test_data_pl" } } ,placementId);

//(Optional configuration) Set the channel information. Developers can use this channel information to distinguish and view the advertising data of each channel in the background.
//Note: If the initCustomMap() method is used, this method must be called after the initCustomMap() method
ATSDKAPI.setChannel("unity3d_test_channel"); 

//(Optional configuration) Set the sub-channel information. Developers can use this channel information to distinguish the sub-channel advertising data of each channel in the background.
//Note: If the initCustomMap() method is used, this method must be called after the initCustomMap() method
ATSDKAPI.setSubChannel("unity3d_test_subchannel"); 

//Set up the Debug log (it is strongly recommended to turn it on during the testing phase to facilitate troubleshooting)
ATSDKAPI.setLogDebug(true);

//(Must be configured) SDK initialization
ATSDKAPI.initSDK("a5c4ad280995c9", "7b4e37f819dbee652ef79c4506e14288");//Use your own app_id & app_key here

3. Access to different advertising forms

Complete initialization After that, you can start accessing each advertising form:

Rewarded video ad access
Interstitial ad access
Banner advertising integration
Native advertising integration
Splash advertising access

Previous
TopOn Unity3D Plugin (2.0.0+) import instructions
Next
Rewarded Video Ad
Last modified: 2025-05-30Powered by