Menu

Import and configure

1. Overview

Flutter version requirement: flutter: ">=2.12.0"

iOS SDK version requirements:

Flutter SDK Version iOS SDK Version
<= 1.0.8 6.4.93
>=1.0.9 6.5.34、6.5.43

You can follow the Account and Related ID Preparation guide for account registration and login instructions.

3. Import Flutter SDK

See the Demo Flutter Demo Github (click to jump)

Two methods for importing the SDK are supported:

3.1 Import from pub.dev

1. Run the following command in the terminal command line: (Refer to https://pub.dev/packages/anythink_sdk )

Copy
flutter pub add anythink_sdk

After running the command, the following code will be automatically added to the project's pubspec.yaml and trigger flutter pub get. You can also manually add the following code in pubspec.yaml:

Copy
dependencies:
  anythink_sdk: ^x.x.x

2. After successful, you can import the following header file and use it:

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

3.2 Manual Import

  1. Download the AnyThink_Flutter_SDK compressed package and decompress it.

  2. Add the decompressed files to your project. You can also import the decompressed files into a newly created directory.

  3. Locate pubspec.yaml in the project and add the local dependency:

Copy
anythink_sdk:
  path: ../
  1. Import the header file in the class:
Copy
 import 'package:anythink_sdk/at_index.dart';

4. Import iOS SDK

4.1 Prerequisites

  • The latest version of Xcode
  • CocoaPods 1.15.2 or above installed

4.2 Locate the correct anythink_sdk.podspec file

  • If you use pub.dev to import the Flutter SDK
  1. Import the header file and hover over the imported header file:
  2. Copy the address in the red box and use Finder to open it to find the location of anythink_sdk.podspec.
  • If you manually import the Flutter SDK

The target file is the anythink_sdk.podspec file in your project directory.

4.3 Get iOS SDK Cocoapods Code

Please click here to go to the SDK Download Center, select the platforms you need to integrate, choose "Yes" for CocoaPods integration, and click Generate Integration Code. (Using iOS 6.4.87 as an example, it is recommended to use the latest version of the iOS SDK.)

4.4 Add iOS SDK Dependencies in the correct anythink_sdk.podspec

Convert the CocoaPods reference code generated in the previous step into the code required by the .podspec file, then fill it into anythink_sdk.podspec. The conversion before and after is as follows:

Copy
// Before conversion:
pod 'AnyThinkiOS','x.x.xx'
pod 'AnyThinkBaiduSDKAdapter','x.x.xx'
pod 'AnyThinkKuaiShouSDKAdapter',''x.x.xx'
pod 'AnyThinkTTSDKAdapter','x.x.xx'
pod 'AnyThinkGDTSDKAdapter','x.x.xx'


Simply replace pod with s.dependency

// After conversion:
s.dependency 'AnyThinkiOS','x.x.xx'
s.dependency 'AnyThinkBaiduSDKAdapter','x.x.xx'
s.dependency 'AnyThinkKuaiShouSDKAdapter','x.x.xx'
s.dependency 'AnyThinkTTSDKAdapter','x.x.xx'
s.dependency 'AnyThinkGDTSDKAdapter','x.x.xx'

4.5 Install iOS SDK

After writing anythink_sdk.podspec, use the terminal to open the iOS podfile directory and wait for the installation to complete. (If this is not the first time, you may need to delete podfile.lock before executing the command below.)

Copy
pod install --repo-update

5. Configure iOS Project

5.1 Update Info.plist

5.1.1 Open Info.plist

5.1.2 Add SKAdNetworkItems Key

Please return to the "SDK Download Center" webpage opened above, and add the content listed in the "SKAdNetwork IDs Code" section to your Info.plist file. Refer to the image below:

5.1.3 Add LSApplicationQueriesSchemes Key

Please return again to the "SDK Download Center" webpage opened above, or directly copy the code below, and add the content listed in the following section to your Info.plist file. Refer to the image below:

5.1.4 Add NSUserTrackingUsageDescription Key

Starting from iOS 14.5, apps can access the user's IDFA data and serve targeted ads to users only after obtaining the user's explicit permission.

Before the app calls the App Tracking Transparency framework to make an app tracking authorization request to the end user, IDFA will be unavailable. If an app does not make this request, the read IDFA will return a string of all zeros.

Copy
<key>NSUserTrackingUsageDescription</key>
<string>Modify this to the permission request description you want users to see, can be localized</string>

5.1.5 Add NSAppTransportSecurity Key

After iOS 10, when the Allow Arbitrary Loads in Web Content key exists, it ignores the Allow Arbitrary Loads setting.

Copy
<key>NSAppTransportSecurity</key>
<dict>
	<key>NSAllowsArbitraryLoads</key>
	<true></true>
</dict>

5.1.6 AdMob Platform: Add GADApplicationIdentifier Key (Optional)

Only add this key if you have selected and are using the Admob platform. For more information, go here.

Copy
<key>GADApplicationIdentifier</key>
<string>Your GADApplicationIdentifier </string>
<!-- Example format of the above value: ca-app-pub-9488501426181082~7319780494   -->

5.2 Set -ObjC

6. Import Android SDK

6.1 Register Plugin

Register the SDK plugin in the GeneratedPluginRegistrant class of the generated Android project:

Copy
public final class GeneratedPluginRegistrant {
  public static void registerWith(@NonNull FlutterEngine flutterEngine) {
    flutterEngine.getPlugins().add(new com.anythink.flutter.AnythinkSdkPlugin());
  }
}

6.2 Download and Import Android Native SDK

1. Go to the Official Website Download Page, select the platforms you need to integrate, and click download. After downloading, decompress the resulting Android SDK compressed package.

  1. (If there is a libs directory in the compressed package and there are files in the libs directory) Copy the libs directory from the Android SDK compressed package to the plugins/anythink_sdk/android/ directory, and add the following configuration in the project's build.gradle:
Copy
dependencies {
    api fileTree(dir: '<plugins>/android/libs', include: ['*.aar', '*.jar'])
}</plugins>

Note: Replace with the actual path where the anythink_sdk folder is placed in the project.

  1. (If there is a build.gradle file in the compressed package) Copy the content from the compressed package's build.gradle into the project's build.gradle.

  2. (If there is a res directory in the compressed package and there are files in the res directory) Copy the content from the res directory in the Android SDK compressed package correspondingly into the project's res directory.

7. Android Project Configuration

7.1 AndroidManifest Configuration

1. Add the content from the AndroidManifest.xml in the Android SDK compressed package to the AndroidManifest.xml in the project.

2. If Admob is integrated, the following configuration must be added to AndroidManifest.xml (the value should be configured with the ID of the app created in the Admob dashboard):

Copy
<manifest>
    <application>
        <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"></meta-data>
    </application>
</manifest>

For details, see the Admob configuration documentation: Update your AndroidManifest.xml

7.2 Android 9 and Above Adaptation

Please refer to: Android Integration and Initialization

7.3 SDK Obfuscation Configuration

1. Flutter SDK obfuscation configuration

Copy
-keep public class com.anythink.flutter.**
-keepclassmembers class com.anythink.flutter.** {
   public *;
}

2. Android SDK ad platform obfuscation configuration

Please refer to the proguard-android.txt content in the Android SDK compressed package.

Previous
Flutter Guide
Next
Initialization instructions
Last modified: 2026-07-01Powered by