Перейти к содержимому

Configuration

Это содержимое пока не доступно на вашем языке.

Add affise_attribution_lib to your pubspec.yaml:

dependencies:
affise_attribution_lib: ^1.7.18

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
path: affise_attribution_lib

path: affise_attribution_lib is required: since 1.7.14/1.7.15 the plugin lives in the affise_attribution_lib/ subdirectory of the repository.

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

dependencies:
affise_attribution_lib: ^1.7.18
affise_attribution_module_adservice: ^1.7.18
affise_attribution_module_advertising: ^1.7.18
affise_attribution_module_androidid: ^1.7.18
affise_attribution_module_appsflyer: ^1.7.18
affise_attribution_module_google: ^1.7.18
affise_attribution_module_huawei: ^1.7.18
affise_attribution_module_link: ^1.7.18
affise_attribution_module_meta: ^1.7.18
affise_attribution_module_network: ^1.7.18
affise_attribution_module_persistent: ^1.7.18
affise_attribution_module_phone: ^1.7.18
affise_attribution_module_rustore: ^1.7.18
affise_attribution_module_status: ^1.7.18
affise_attribution_module_subscription: ^1.7.18
affise_attribution_module_tiktok: ^1.7.18
PackageAndroidiOS
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).

You can also add the native modules to android/app/build.gradle / ios/Podfile manually, as described on each module page. The README recommends the Flutter packages above instead.

final affise_version = '1.7.18'
dependencies {
// Affise modules
implementation "com.affise:module-advertising:$affise_version"
implementation "com.affise:module-androidid:$affise_version"
implementation "com.affise:module-hardware:$affise_version"
implementation "com.affise:module-link:$affise_version"
implementation "com.affise:module-network:$affise_version"
implementation "com.affise:module-phone:$affise_version"
// ...
}

Available Android modules: ADVERTISING, ANDROIDID, APPSFLYER, HARDWARE, LINK, NETWORK, PHONE, STATUS, SUBSCRIPTION, RUSTORE, HUAWEI, META, TIKTOK.

HARDWARE (new in native 1.7.18) has no Flutter wrapper package — it can only be added natively. See Hardware module.

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.