Skip to content

Optional setup

The AffiseSettings builder returned by Affise.settings(...) exposes fluent methods that mirror fields on AffiseInitProperties. All methods return the same AffiseSettings instance so you can chain them before start().

All declared in lib/settings/affise_settings.dart:

| Method | Line | |---|---| | setProduction(bool production) | :30 | | setDomain(String domain) | :36 | | setPartParamName(String partParamName) | :42 | | setPartParamNameToken(String partParamNameToken) | :48 | | setAppToken(String appToken) | :54 | | setOnInitSuccess(OnInitSuccessHandler onInitSuccessHandler) | :72 | | setOnInitError(OnInitErrorHandler onInitErrorHandler) | :78 | | setConfigValue(AffiseConfig key, dynamic value) | :84 | | setConfigValues(Map<AffiseConfig, dynamic> values) | :90 | | setDisableModules(List<AffiseModules> disableModules) | :98 | | start() | :122 |

Affise
.settings(
affiseAppId: "Your appId",
secretKey: "Your SDK secretKey",
)
.setProduction(false)
.setDomain("https://YoureCustomDomain/") // Set custom domain
.start(); // Start Affise SDK
Affise
.settings(
affiseAppId: "Your appId",
secretKey: "Your SDK secretKey",
)
.setOnInitSuccess(() {
// Called if library initialization succeeded
print("Affise: init success");
})
.setOnInitError((error) {
// Called if library initialization failed
print("Affise: init error $error");
})
.start(); // Start Affise SDK

Callback typedefs:

  • typedef OnInitSuccessHandler = void Function(); (lib/settings/on_init_success_handler.dart:1)
  • typedef OnInitErrorHandler = void Function(String e); (lib/settings/on_init_error_handler.dart:1)
enum AffiseConfig {
FB_APP_ID;
}

Declared at lib/settings/affise_config.dart:3-10. Native key mapping (:12-19): AffiseConfig.FB_APP_ID → "fb_app_id".

The FB_APP_ID value is consumed by the Meta module:

Affise
.settings(
affiseAppId: "Your appId",
secretKey: "Your SDK secretKey",
)
.setConfigValue(AffiseConfig.FB_APP_ID, "Your Facebook App Id")
.start(); // Start Affise SDK
Affise
.settings(
affiseAppId: "Your appId",
secretKey: "Your SDK secretKey",
)
.setDisableModules([
// Exclude modules from start
AffiseModules.ADVERTISING,
AffiseModules.SUBSCRIPTION,
])
.start(); // Start Affise SDK

Enumeration: see Modules overview.

Declared in lib/affise_init_properties.dart:9-54. All fields are exposed by the builder methods above.

| Field | Dart type | Default | Line | |---|---|---|---| | affiseAppId | String? | null (constructor required) | :10, ctor :25 | | isProduction | bool | true | :11, ctor :27 | | partParamName | String? | null | :12, ctor :28 | | partParamNameToken | String? | null | :13, ctor :29 | | appToken | String? | null | :14, ctor :30 | | secretKey | String? | null (constructor required) | :15, ctor :26 | | autoCatchingClickEvents | List<AutoCatchingType>? | null (ctor arg commented out) | :16, ctor :32 | | enabledMetrics | bool | false (ctor arg commented out) | :17, ctor :31 | | domain | String? | null | :18, ctor :33 | | onInitSuccessHandler | OnInitSuccessHandler? | null | :19, ctor :34 | | onInitErrorHandler | OnInitErrorHandler? | null | :20, ctor :35 | | configValues | Map<AffiseConfig, dynamic> | const {} | :21, ctor :36 | | disableModules | List<AffiseModules> | const [] | :22, ctor :37 |

The toMap getter (lib/affise_init_properties.dart:40-54) sends these keys to native: affiseAppId, isProduction, partParamName, partParamNameToken, appToken, secretKey, autoCatchingClickEvents, enabledMetrics, domain, configStrings, disableModules.

Affise.setSecretKey("new secret");

Signature: lib/affise.dart:49. Dispatches AffiseApiMethod.SET_SECRET_KEY (lib/native/affise_native.dart:75-77).