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;

  • 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: 'your appid', 
         appidkeyStr: 'your 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'},
    );
  }
  // Initialize Taku SDK
  initTaku() async {
    await ATInitManger.initAnyThinkSDK(
        appidStr: Configuration.appidStr,
        appidkeyStr: Configuration.appidkeyStr);
  }

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. 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-08-04Powered by