Menu

Initialization instructions

• Your App must formulate a Privacy Policy, display it to users when they launch the App for the first time, and obtain their consent. For the Privacy Policy formulated by the App, please refer to the Privacy Compliance Guide.

It is imperative to ensure that the TopOn SDK is initialized only after the user has consented to the App's Privacy Policy.

  • Before loading and displaying ads using the SDK, you need to call the initSDK method;

• For EU regions or related user privacy agreement controls, you can control data reporting permissions through setGDPRLevel;

• You can enable debug logs using the setLogEnabled method to facilitate troubleshooting issues encountered during SDK integration;

• Parameters such as appid and appkey required by the SDK can be obtained after creating an app in the developer backend.

1. SDK Initialization

You can initialize the SDK with the following code. Additionally, since ad loading is asynchronous, to obtain the ad status, please implement the listener methods for each ad type.

Import AT SDK import 'package:secmtp_sdk/at_index.dart';

Copy
 _initTopon() async { 
     await ATInitManager.initAnyThinkSDK( 
         appidStr: 'your appid', 
         appidkeyStr: 'your appkey')
  }

Complete Sample Code:

Copy
import 'package:secmtp_sdk/at_index.dart';
import '../configuration_sdk.dart';

final InitManger = InitTool();

class InitTool{
  // Enable SDK Debug logs. It is highly recommended to enable this during testing to facilitate troubleshooting.
  setLogEnabled() async {
    await ATInitManger
        .setLogEnabled(
      logEnabled: true,
    );
  }
  // Set channel, which can be used for data statistics and traffic grouping
  setChannelStr() async {
    await ATInitManger
        .setChannelStr(
      channelStr: "test_setChannel",
    );
  }
  // Set subchannel, which can be used for data statistics and traffic grouping
  setSubchannelStr() async {
    await ATInitManger
        .setSubChannelStr(
      subchannelStr: "test_setSubchannelStr",
    );
  }
  // Set custom Map information to match the corresponding traffic grouping configured in the backend (App level) (optional configuration)
  setCustomDataDic() async {
    await ATInitManger.setCustomDataMap(
      customDataMap: {
        'setCustomDataDic': 'myCustomDataDic',
      },
    );
  }
  // Set excluded cross-promotion App list
  setExludeBundleIDArray() async {
    await ATInitManger.setExludeBundleIDArray(
      exludeBundleIDList: ['test_setExludeBundleIDArray'],
    );
  }
  // Set custom Map information to match the corresponding traffic grouping configured in the backend (Placement level) (optional configuration)
  setPlacementCustomData() async {
    await ATInitManger.setPlacementCustomData(
      placementIDStr: 'b5b72b21184aa8',
      placementCustomDataMap: {'setPlacementCustomData': 'test_setPlacementCustomData'},
    );
  }
  // Determine if the user is located in the EU region
  getUserLocation() async {
    await ATInitManger.getUserLocation().then((value) {
      print('flutter: Get user location -- ${value.toString()}');
    });
  }
  // Get GDPR authorization level
  getGDPRLevel() async {
    await ATInitManger.getGDPRLevel().then((value) {
      print('flutter:Get GDPR --${value.toString()}');
    });
  }
  setDataConsentSet() async {

    await ATInitManger.setDataConsentSet(
        gdprLevel:
    ATInitManger.dataConsentSetPersonalized());
  }

  deniedUploadDeviceInfo() async {

    await ATInitManger
        .deniedUploadDeviceInfo(
        deniedUploadDeviceInfoList: [ATInitManger.aOAID()]);
  }
  // Initialize TopOn SDK
  initTopon() async {
    await ATInitManger.initAnyThinkSDK(
        appidStr: Configuration.appidStr,
        appidkeyStr: Configuration.appidkeyStr);
  }
  // Display GDPR authorization interface (deprecated in v6.2.87, use showGDPRConsentDialog() instead)
  showGDPRAuth()async{
    await ATInitManger.showGDPRAuth();
  }
  // v6.2.87+, Display GDPR interface (UMP)
  showGDPRConsentDialog()async{
    await ATInitManger.showGDPRConsentDialog();
  }
  
  
  // Get GDPR listener event callbacks
  initListen() {
    ATListenerManager.initEventHandler.listen((value) {

      if (value.userLocation != null) {
        switch (value.userLocation) {
          case InitUserLocation.initUserLocationInEU:
            print("flutter Monitor initial user location in the EU--");

            ATInitManger.getGDPRLevel().then((value) {
              if (value == ATInitManger.dataConsentSetUnknown()) {
                showGDPRAuth();
              }
            });
            break;
          case InitUserLocation.initUserLocationOutOfEU:
            print("flutter: flutter The location of the listening initial user is not in the EU");
            break;
          case InitUserLocation.initUserLocationUnknown:
            print("flutter: flutter The location of the initial listening user is unknown");
            break;
        }
      }
      
      if (value.consentDismiss != null) {
        print("flutter: flutter consent dismiss callback");
      }
      
    });
  }
}

Import TU SDK import 'package:thinkup_sdk/at_index.dart';

Copy
 _initTopon() async { 
     await ATInitManager.initAnyThinkSDK( 
         appidStr: 'your appid', 
         appidkeyStr: 'your appkey')
  }

Complete Sample Code:

Copy
import 'package:thinkup_sdk/at_index.dart';
import '../configuration_sdk.dart';

final InitManger = InitTool();

class InitTool{
  // Enable SDK Debug logs. It is highly recommended to enable this during testing to facilitate troubleshooting.
  setLogEnabled() async {
    await ATInitManger
        .setLogEnabled(
      logEnabled: true,
    );
  }
  // Set channel, which can be used for data statistics and traffic grouping
  setChannelStr() async {
    await ATInitManger
        .setChannelStr(
      channelStr: "test_setChannel",
    );
  }
  // Set subchannel, which can be used for data statistics and traffic grouping
  setSubchannelStr() async {
    await ATInitManger
        .setSubChannelStr(
      subchannelStr: "test_setSubchannelStr",
    );
  }
  // Set custom Map information to match the corresponding traffic grouping configured in the backend (App level) (optional configuration)
  setCustomDataDic() async {
    await ATInitManger.setCustomDataMap(
      customDataMap: {
        'setCustomDataDic': 'myCustomDataDic',
      },
    );
  }
  // Set excluded cross-promotion App list
  setExludeBundleIDArray() async {
    await ATInitManger.setExludeBundleIDArray(
      exludeBundleIDList: ['test_setExludeBundleIDArray'],
    );
  }
  // Set custom Map information to match the corresponding traffic grouping configured in the backend (Placement level) (optional configuration)
  setPlacementCustomData() async {
    await ATInitManger.setPlacementCustomData(
      placementIDStr: 'b5b72b21184aa8',
      placementCustomDataMap: {'setPlacementCustomData': 'test_setPlacementCustomData'},
    );
  }
  // Determine if the user is located in the EU region
  getUserLocation() async {
    await ATInitManger.getUserLocation().then((value) {
      print('flutter: Get user location -- ${value.toString()}');
    });
  }
  // Get GDPR authorization level
  getGDPRLevel() async {
    await ATInitManger.getGDPRLevel().then((value) {
      print('flutter:Get GDPR --${value.toString()}');
    });
  }
  setDataConsentSet() async {

    await ATInitManger.setDataConsentSet(
        gdprLevel:
    ATInitManger.dataConsentSetPersonalized());
  }

  deniedUploadDeviceInfo() async {

    await ATInitManger
        .deniedUploadDeviceInfo(
        deniedUploadDeviceInfoList: [ATInitManger.aOAID()]);
  }
  // Initialize TopOn SDK
  initTopon() async {
    await ATInitManger.initAnyThinkSDK(
        appidStr: Configuration.appidStr,
        appidkeyStr: Configuration.appidkeyStr);
  }
  // Display GDPR authorization interface (deprecated in v6.2.87, use showGDPRConsentDialog() instead)
  showGDPRAuth()async{
    await ATInitManger.showGDPRAuth();
  }
  // v6.2.87+, Display GDPR interface (UMP)
  showGDPRConsentDialog()async{
    await ATInitManger.showGDPRConsentDialog();
  }
  
  
  // Get GDPR listener event callbacks
  initListen() {
    ATListenerManager.initEventHandler.listen((value) {

      if (value.userLocation != null) {
        switch (value.userLocation) {
          case InitUserLocation.initUserLocationInEU:
            print("flutter Monitor initial user location in the EU--");

            ATInitManger.getGDPRLevel().then((value) {
              if (value == ATInitManger.dataConsentSetUnknown()) {
                showGDPRAuth();
              }
            });
            break;
          case InitUserLocation.initUserLocationOutOfEU:
            print("flutter: flutter The location of the listening initial user is not in the EU");
            break;
          case InitUserLocation.initUserLocationUnknown:
            print("flutter: flutter The location of the initial listening user is unknown");
            break;
        }
      }
      
      if (value.consentDismiss != null) {
        print("flutter: flutter consent dismiss callback");
      }
      
    });
  }
}

Enable SDK Debug logs. It is highly recommended to enable this during testing to facilitate troubleshooting.

Copy
  _setLogEnabled() async {
    await ATInitManager
        .setLogEnabled(
      logEnabled: true,
    );
  }

2. App Custom Rules

2.1 Set Channel

Copy
  _setChannelStr() async {
    await ATInitManager
        .setChannelStr(
      channelStr: "123",
    );
  }

2.2 Set Subchannel

Copy
_setSubchannelStr() async {
    await ATInitManager
        .setSubchannelStr(
      subchannelStr: "456",
    );
  }

2.3 Set Custom Map Information

Can be used to match the corresponding traffic grouping configured in the backend (App level) (optional configuration)

Copy
 _setCustomDataDic() async {
    await ATInitManager.setCustomDataMap(
      customDataMap: {
        '1': 'a',
      },
    );
  }

2.4 Set Placement Custom Map Information

Can be used to match the corresponding traffic grouping configured in the backend (Placement level) (optional configuration)

Copy
  _setPlacementCustomData() async {
    await ATInitManager.setPlacementCustomData(
      placementIDStr: '4',
      placementCustomDataMap: {'b': '4'},
    );
  }

3. Cross-Promotion

Set the excluded cross-promotion App list to remove items that do not require ad promotion, passing in an array of the project's App IDs (IDs from the Apple Developer backend).

Copy
 _setExludeBundleIDArray() async {
    await ATInitManager.setExludeBundleIDList(
      exludeBundleIDList: ['3'],
    );
  }

4. GDPR Explanation

GDPR is the abbreviation of the General Data Protection Regulation issued by the EU on May 25, 2018. If your project needs to be released in the EU region, please complete the integration.

4.1 Google UMP (v6.2.87+)

Please refer to the Android Google UMP Adaptation and Usage Guide and iOS Google UMP Adaptation and Usage Guide to complete UMP integration and configuration, and use the following APIs to display the UMP GDPR pop-up and initialize the SDK.

Copy
  // v6.2.87+, Display GDPR interface (UMP)
  showGDPRConsentDialog()async{
    await ATInitManger.showGDPRConsentDialog();
  }
  
  // Get GDPR listener event callbacks
  initListen() {
    ATListenerManager.initEventHandler.listen((value) {
      // Note: SDK initialization must be performed in this callback, and ad loading can only be initiated after initialization
      if (value.consentDismiss != null) {
        print("flutter: flutter consent dismiss callback");
      }
    });
  }

Note: Ad requests must be initiated only after the SDK is initialized.

4.2 Get GDPR Level

Copy
 _getGDPRLevel() async {
    await ATInitManager.getGDPRLevel().then((value) {
      print('Get GDPR level');
    });
  }

4.3 Set GDPR Level (Versions below v6.2.87)

ATInitManager.dataConsentSetPersonalized(): This level indicates that the user consents to the SDK collecting and using their personal data to provide more relevant and suitable ads for them.

ATInitManager.dataConsentSetNonpersonalized(): If the data protection level is set to this value, the SDK will not collect the user's personal data, so the ads provided may not be tailored to the user's situation. Additionally, in this case, certain data that does not involve user privacy may still be collected.

Copy
   setDataConsentSet() async {

    await ATInitManager.setDataConsentSet(
        gdprLevel:
    ATInitManager.dataConsentSetPersonalized());
  }

Determine if the user is located in the EU region for processing during initialization for EU regions

Copy
  _getUserLocation() async {
    await ATInitManager.getUserLocation();
  }

If located in the EU region and the level is UNKNOWN, display the authorization pop-up

Copy
  showGDPRAuth()async{
    await ATInitManager.showGDPRAuth();
  }

  initListen() {
    ATListenerManager.initEventHandler.listen((value) {
      switch (value.userLocation) {
        case InitUserLocation.initUserLocationInEU:
          print("flutter: Monitor initial user location is in the EU--");

          ATInitManager.getGDPRLevel().then((value) {
              if (value == ATInitManager.dataConsentSetUnknown()) {
                showGDPRAuth();
              }
          });

          break;
        case InitUserLocation.initUserLocationOutOfEU:
          print("flutter: Monitor initial user location is not in the EU");
          break;
        case InitUserLocation.initUserLocationUnknown:
          print("flutter: Monitor initial user location is unknown");
          break;
      }
    });
  }

5. Restrict Reporting of Privacy Data

Note: When developers restrict the reported device data, it may affect the normal use of TopOn functions, such as traffic grouping, cross-promotion, TopOn Adx, etc.

Please set this carefully.

Copy
deniedUploadDeviceInfo() async {

    await ATInitManager
        .deniedUploadDeviceInfo(
        deniedUploadDeviceInfoList: [
          ATInitManager.aVersionNameKey(),
          ATInitManager.aVersionCodeKey(),
          ATInitManager.aPackageNameKey(),
          ATInitManager.aAppVersionNameKey(),
          ATInitManager.aAppVersionCodeKey(),
          ATInitManager.aBrandKey(),
          ATInitManager.aModelKey(),
          ATInitManager.aScreenKey(),
          ATInitManager.aNetworkTypeKey(),
          ATInitManager.aMNCKey(),
          ATInitManager.aMCCKey(),
          ATInitManager.aLanguageKey(),
          ATInitManager.aTimeZoneKey(),
          ATInitManager.aUserAgentKey(),
          ATInitManager.aOrientKey(),
          ATInitManager.aIDFAKey(),
          ATInitManager.aIDFVKey(),
          ATInitManager.aANDROID(),
          ATInitManager.aGAID(),
          ATInitManager.aINSTALLER(),
          ATInitManager.aMAC(),
          ATInitManager.aIMEI(),
          ATInitManager.aOAID(),

        ]);
  }

Parameter Description:

Key Note
ATInitManager.aVersionNameKey() System version name
ATInitManager.aVersionCodeKey() System version code
ATInitManager.aPackageNameKey() App package name
ATInitManager.aAppVersionNameKey() App version name
ATInitManager.aAppVersionCodeKey() App version code
ATInitManager.aBrandKey() Device brand
ATInitManager.aModelKey() Device model
ATInitManager.aScreenKey() Screen resolution
ATInitManager.aNetworkTypeKey() Network type
ATInitManager.aMNCKey() Mobile Network Code (MNC)
ATInitManager.aMCCKey() Mobile Country Code (MCC)
ATInitManager.aLanguageKey() System language
ATInitManager.aTimeZoneKey() Time zone
ATInitManager.aUserAgentKey() User Agent
ATInitManager.aOrientKey() Screen orientation
ATInitManager.aIDFAKey() IDFA
ATInitManager.aIDFVKey() IDFV
ATInitManager.aANDROID() Android ID
ATInitManager.aGAID() Google Ad ID
ATInitManager.aINSTALLER() App installation source
ATInitManager.aMAC() MAC address
ATInitManager.aIMEI() International Mobile Equipment Identity (IMEI)
ATInitManager.aOAID() OAID
Previous
Import and configure
Next
Splash ads
Last modified: 2026-01-07Powered by