Appstack Flutter Plugin

Track events and revenue with Apple Search Ads attribution in your Flutter app.

License

pub.dev repository

Here, you will find the pub.dev appstack_plugin documentation. Please use the latest available version of the SDK.

Requirements

iOS

  • iOS version: 13.0+ (14.3+ recommended for Apple Ads)
  • Xcode: 14.0+

Android

  • Minimum SDK: Android 5.0 (API level 21)
  • Target SDK: 34+

General

  • Flutter: 3.3.0+
  • Dart: 2.18.0+

Initial setup

Advanced usage

Attribution parameters

Two methods are available to retrieve attribution parameters:

Method Mechanism When to use
getAttributionParams() Future — request/response over method channel Simple use cases where timing is predictable
getAttributionParamsWithCallback() Stream — native background thread pushes result When retrieval time may vary; frees the platform thread immediately

getAttributionParams()

final params = await AppstackPlugin.getAttributionParams();
if (params != null) {
  print('Attribution params: $params');
}

getAttributionParamsWithCallback()

Spawns a native background thread (Swift Task.detached on iOS, Thread on Android). The stream emits exactly one value then closes.

AppstackPlugin.getAttributionParamsWithCallback().listen(
  (params) {
    if (params != null) {
      print('Attribution params: $params');
    }
  },
  onError: (e) => print('Error: $e'),
);

Checking SDK status

After calling configure(), you can verify the SDK was enabled (for example, that the API key is valid). isSdkDisabled() returns true when the SDK is disabled.

await AppstackPlugin.configure('your-api-key');
if (await AppstackPlugin.isSdkDisabled()) {
  print('SDK is disabled - check your API key');
}

Getting the Appstack ID

Retrieve the unique Appstack ID for the current user. Returns null if it is not available yet.

final appstackId = await AppstackPlugin.getAppstackId();
print('Appstack ID: $appstackId');

Environment-based configuration

Set up different API keys for different environments:

// Use environment variables or configuration
final apiKey = Platform.isIOS 
    ? const String.fromEnvironment('APPSTACK_IOS_API_KEY')
    : const String.fromEnvironment('APPSTACK_ANDROID_API_KEY');

await AppstackPlugin.configure(apiKey);

Platform-specific considerations

iOS

Apple Ads attribution:

  • Only works on iOS 14.3+
  • Requires app installation from App Store or TestFlight
  • Attribution data appears within 24-48 hours
  • User consent may be required for detailed attribution (iOS 14.5+)
if (Platform.isIOS) {
  await AppstackPlugin.enableAppleAdsAttribution();
}

Android

Play Store Attribution

  • Install referrer data collected automatically
  • Attribution available immediately for Play Store installs
  • Works with Android 5.0+ (API level 21)

Cross-platform best practices

Future<void> initializeSDK() async {
  final apiKey = Platform.isIOS 
      ? 'your-ios-api-key' 
      : 'your-android-api-key';

  await AppstackPlugin.configure(apiKey);

  if (Platform.isIOS) {
    await AppstackPlugin.enableAppleAdsAttribution();
  }
}

Limitations

Attribution timing

  • iOS: Apple Ads attribution data appears within 24-48 hours after install
  • Android: Install referrer data available immediately for Play Store installs
  • Attribution only available for apps installed from official stores

Platform constraints

  • iOS: Requires iOS 14.3+
  • Android: Minimum API level 21 (Android 5.0)
  • Flutter: 3.3.0+
  • Some Apple Ads features may not work in development/simulator environments

Event tracking

  • Event names are case-sensitive and standardized
  • For revenue events, always pass a revenue (or price) and a currency parameter
  • The SDK must be initialized before any tracking calls
  • enableAppleAdsAttribution() only works on iOS and returns false on Android
  • Network connectivity required for event transmission (events are queued offline)

Support

For questions or issues:

  1. Check the GitHub Repository
  2. Contact our support team at support@appstack.tech
  3. Open an issue in the repository