AppsFlyer

The Magify Flutter SDK does not depend on the AppsFlyer SDK. If your app already integrates appsflyer_sdk for attribution, forward its acquisition-cost data to Magify with a single call.

Linking by user ID

To make AppsFlyer and Magify report the same user, both SDKs must use the same identifier. There are two ways to do it.

Magify clientId is passed to AppsFlyer

Initialize Magify first, then set its clientId as the AppsFlyer customer user ID before starting AppsFlyer, so attribution is linked to the Magify user from the first session:

await MagifyClient.instance.init(config);

final clientId = await MagifyClient.instance.clientId;

final appsflyerSdk = AppsflyerSdk(appsFlyerOptions);
appsflyerSdk.setCustomerUserId(clientId);
await appsflyerSdk.initSdk(...);

AppsFlyer UID is passed to Magify

If you want AppsFlyer's own identifier to be the Magify clientId, read it first and pass it in MagifyConfig.clientId at init time:

final appsflyerSdk = AppsflyerSdk(appsFlyerOptions);
await appsflyerSdk.initSdk(...);

final appsFlyerUid = await appsflyerSdk.getAppsFlyerUID();

await MagifyClient.instance.init(
  MagifyConfig(
    applicationName: 'MyApplication',
    defaultConfig: 'assets/magify_default_config.json',
    isSandbox: false,
    clientId: appsFlyerUid,
  ),
);

setAppsFlyerCostData

Future<void> setAppsFlyerCostData(Map<String, Object> conversionInfo)

Call it with the conversion-data payload as AppsFlyer delivers it — do not reshape it first. The SDK reads the map as follows:

  1. If cost_cents_USD is present, it is used directly.
  2. Otherwise, af_cost_value combined with af_cost_currency is used.
  3. Either way, a supported af_cost_model is required: cpi, cpc, cpm or cpa. Without one of these four values, the cost data is ignored.
  4. Any other key in the map is ignored.

Wiring it up

Feed the payload from AppsFlyer's conversion-data callback straight into setAppsFlyerCostData, after MagifyClient.instance.init has completed:

import 'package:appsflyer_sdk/appsflyer_sdk.dart';
import 'package:magify_flutter_sdk/magify_sdk.dart';

void onConversionDataSuccess(Map<dynamic, dynamic> data) {
  final conversionInfo = Map<String, Object>.from(data);
  MagifyClient.instance.setAppsFlyerCostData(conversionInfo);
}

// When wiring up the AppsFlyer SDK:
appsflyerSdk.onInstallConversionData(onConversionDataSuccess);

Notes

  • This is a one-way call — there is no getter to read back what was reported.
  • It does not block Magify's own startup: the first context request to the Magify backend goes out without cost data if AppsFlyer hasn't resolved it yet, and the config is reloaded once setAppsFlyerCostData is called.
  • Calling it again replaces the previously reported cost data. A call with a map that fails validation (missing/unsupported af_cost_model, and no cost_cents_USD) leaves the previous value untouched.

Next step

See Adjust if you also integrate Adjust, or Your own integration for the general pattern this call follows.

Related articles

CampaignsProvider

iOS SDK Lifecycle

IInAppStore

Unity SDK API Collection

Android

Your own integration