Skip to content

Is There a Way to Handle AppsFlyer Dynamic Links in Flutter/Dart Without Native AppDelegate Code on iOS? #394

@YawarOsman

Description

@YawarOsman

Description

In our Flutter app using the appsflyer_sdk package, dynamic links fail to work when the app is launched from a terminated state on iOS. Specifically, when the app is fully closed and then opened via a dynamic link, the link data isn't captured unless specific initialization code is added to the AppDelegate.swift file.


Problem Details

  • When the app is in memory (running or in the background), dynamic links work as expected.
  • When the app is terminated, dynamic links are not captured unless the following code is included in AppDelegate.swift:
let afLib = AppsFlyerLib.shared()
afLib.appleAppID = "6746770983"
afLib.appsFlyerDevKey = "aBMTads******tP7NzpK"
afLib.waitForATTUserAuthorization(timeoutInterval: 10)
afLib.isDebug = true
afLib.start()

What I'm Asking

Is there a way to handle dynamic links entirely in Flutter/Dart for iOS when the app is launched from a terminated state, without adding native code to AppDelegate.swift? Or is the native initialization in AppDelegate the only way to capture deep link data in this scenario?

For example:
Can the appsflyer_sdk package be configured in Dart to catch initial deep link data on iOS without native setup?

My Flutter code initializes the AppsFlyer SDK in Dart with the same keys and settings, but it seems to miss deep link data when the app is terminated because the Flutter engine starts too late. Here's a snippet of my Dart initialization:
dart

final appsFlyerOptions = AppsFlyerOptions(
  afDevKey: dotenv.env['APP_FLYER_DEV_KEY']!,
  appId: dotenv.env['APP_FLYER_APP_ID']!,
  showDebug: true,
  timeToWaitForATTUserAuthorization: 10,
  disableAdvertisingIdentifier: false,
  disableCollectASA: false,
);
_appsflyerSdk = AppsflyerSdk(appsFlyerOptions);
await _appsflyerSdk.initSdk(
  registerConversionDataCallback: true,
  registerOnAppOpenAttributionCallback: true,
  registerOnDeepLinkingCallback: true,
);

Additional Notes
This issue is iOS-specific; Android doesn’t require extra native code and works fine

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions