Skip to content

Configuration

Add affise_attribution_lib to your pubspec.yaml:

dependencies:
affise_attribution_lib: ^1.7.16

Or run flutter pub add affise_attribution_lib.

Alternatively, use a Git dependency:

dependencies:
affise_attribution_lib:
git:
url: https://github.com/affise/affise-mmp-sdk-flutter

Since 1.7.14/1.7.15 every native Affise module is also published as a Flutter wrapper package. Add only the ones you need (each module page lists its package):

dependencies:
affise_attribution_lib: ^1.7.16
affise_attribution_module_adservice: ^1.7.16
affise_attribution_module_advertising: ^1.7.16
affise_attribution_module_androidid: ^1.7.16
affise_attribution_module_appsflyer: ^1.7.16
affise_attribution_module_google: ^1.7.16
affise_attribution_module_huawei: ^1.7.16
affise_attribution_module_link: ^1.7.16
affise_attribution_module_meta: ^1.7.16
affise_attribution_module_network: ^1.7.16
affise_attribution_module_persistent: ^1.7.16
affise_attribution_module_phone: ^1.7.16
affise_attribution_module_rustore: ^1.7.16
affise_attribution_module_status: ^1.7.16
affise_attribution_module_subscription: ^1.7.16
affise_attribution_module_tiktok: ^1.7.16

| Package | Android | iOS | |---|:-:|:-:| | affise_attribution_module_adservice | — | ✓ | | affise_attribution_module_advertising | ✓ | ✓ | | affise_attribution_module_androidid | ✓ | — | | affise_attribution_module_appsflyer | ✓ | ✓ | | affise_attribution_module_google | — | ✓ | | affise_attribution_module_huawei | ✓ | — | | affise_attribution_module_link | ✓ | ✓ | | affise_attribution_module_meta | ✓ | — | | affise_attribution_module_network | ✓ | — | | affise_attribution_module_persistent | — | ✓ | | affise_attribution_module_phone | ✓ | — | | affise_attribution_module_rustore | ✓ | — | | affise_attribution_module_status | ✓ | ✓ | | affise_attribution_module_subscription | ✓ | ✓ | | affise_attribution_module_tiktok | ✓ | ✓ |

The packages have no Dart API — they only add the native module dependency (com.affise:module-* on Android, AffiseModule/* on iOS). Alternatively, add the native dependencies to android/app/build.gradle / ios/Podfile manually, as described on each module page.

Terminal window
flutter pub get

Add the INTERNET permission to your AndroidManifest.xml:

<manifest>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

Call Affise.settings(...) inside your State.initState:

import 'package:flutter/foundation.dart';
import 'package:affise_attribution_lib/affise.dart';
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
Affise
.settings(
affiseAppId: "Your appId", //Change to your app id
secretKey: "Your SDK secretKey", //Change to your SDK secretKey
)
.start(); // Start Affise SDK
}
}

Affise.settings(...) (lib/affise.dart:16) returns an AffiseSettings builder (lib/settings/affise_settings.dart:8). Calling start() (lib/settings/affise_settings.dart:122) schedules the init on the next frame via SchedulerBinding.instance.addPostFrameCallback.

For production/debug mode, custom domain, module disabling, init callbacks, and config values, see Optional setup.