Menu

Initialization instructions

• Your App needs to establish a Privacy Policy, and display the Privacy Policy and obtain user consent when the user launches the App for the first time. For the App's Privacy Policy, please refer to the Privacy Compliance Guide. Be sure to initialize the Taku SDK only after the user has agreed to the App's Privacy Policy.

  • Before using the SDK to load and display ads, you need to call the initSDK method;

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

  • Through the setLogEnabled method, you can enable debug logs to facilitate locating 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 dashboard.

1. SDK Initialization

You can initialize the SDK using the following code. Also, because ad loading is performed asynchronously, if you want to get the ad status, please implement the listener methods for each ad type.

Import ATSDK import 'package:anythink_sdk/at_index.dart';

swift Copy
 _initTaku() async { 
     await ATInitManager.initAnyThinkSDK( 
         appidStr: 'you appid', 
         appidkeyStr: 'you appkey')
  }

Complete sample code:

swift Copy
import 'package:anythink_sdk/at_index.dart';
import '../configuration_sdk.dart';

final InitManger = InitTool();

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

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

  deniedUploadDeviceInfo() async {

         ATInitManger
        .deniedUploadDeviceInfo(
        deniedUploadDeviceInfoList: [ATInitManger.aOAID()]);
    });
  }
  // Initialize Taku SDK
  initTaku() async {
    await ATInitManger.initAnyThinkSDK(
        appidStr: Configuration.appidStr,
        appidkeyStr: Configuration.appidkeyStr);
  }
  // Show GDPR interface (deprecated in v6.2.87, please use showGDPRConsentDialog() instead)
  showGDPRAuth()async{
     ATInitManger.showGDPRAuth();
  }
  // v6.2.87+, Show GDPR interface (UMP)
  showGDPRConsentDialog()async{
     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 log. Strongly recommended to enable during the testing phase for easier troubleshooting.

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

2. App Custom Rules

2.1 Set Channel

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

2.2 Set Sub-Channel

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

2.3 Set Custom Map Information

Can match the corresponding traffic group configured in the dashboard (App level) (optional)

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

2.4 Set Ad Placement-Specific Custom Map Information

Can match the corresponding traffic group configured in the dashboard (Placement level) (optional)

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

3. Cross-Promotion

Set the excluded cross-promotion app list to remove projects that do not need ad promotion, passing in the project's Appid (Apple dashboard ID).

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

4. GDPR Description

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 iOS Google UMP Adaptation and Usage Guide to complete UMP integration and configuration, and use the following API for UMP GDPR consent form and SDK Initialization.

Copy
  // v6.2.87+, Show GDPR interface (UMP)
  showGDPRConsentDialog()async{
     ATInitManger.showGDPRConsentDialog();
  }
  
  // Get GDPR listener event callbacks
  initListen() {
    ATListenerManager.initEventHandler.listen((value) {
      // Note: SDK Initialization must be performed in this callback, and ads should be loaded after Initialization
      if (value.consentDismiss != null) {
        print("flutter: flutter consent dismiss callback");
      }
    });
  }

Note: Ad requests must be initiated after SDK Initialization.

4.2 Get GDPR Level

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

4.3 Set GDPR Level (v6.2.87 and below)

ATInitManager.dataConsentSetPersonalized(): This level means the user agrees to allow the SDK to collect and use their personal data to provide them with more relevant and suitable ads.

ATInitManager.dataConsentSetNonpersonalized(): If the data protection level is set to this value, the SDK will not collect the user's personal data, and the ads served may not match the user's situation. In addition, in this case, certain data not involving user privacy may still be collected.

swift Copy
   setDataConsentSet() async {

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

Determine if located in the EU region and handle accordingly during Initialization

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

If in the EU region and the level is UNKNOWN, execute the authorization dialog

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

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

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

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

5. Restrict Uploading of Privacy Data

Note: When developers restrict the uploaded device data, it may affect the normal functionality of Taku, such as traffic grouping, cross-promotion, Taku Adx, etc. Developers should set this carefully.

swift Copy
deniedUploadDeviceInfo() async {

         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
ATInitManager.aMCCKey() Mobile Country Code
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 install source
ATInitManager.aMAC() MAC address
ATInitManager.aIMEI() International Mobile Equipment Identity
ATInitManager.aOAID() OAID
Previous
Import and configure
Next
Splash ads
Last modified: 2026-07-01Powered by