r/appdev • • 15h ago

AppsFlyer Flutter SDK initialization order? Deep link data only shows up after the first relaunch

Flutter dev at a coffee loyalty app (40ish stores). We added the appsflyer_sdk plugin for our paid installs.

Issue: on a fresh install from a OneLink, the deep link callback is empty on first open. Happens on both iOS and Android, so I don't think it's a platform thing. kill the app, reopen it and suddenly the data's there.

Also not sure where the ATT prompt should go relative to init. Right now it fires on the splash screen before anything else.

Current order in main(): Firebase init, ATT request, AppsflyerSdk(options), initSdk() and then onDeepLinking gets registered later in the home widget.

What's the right order here? Is this a known Flutter thing or am I just doing it wrong.

1 Upvotes

2 comments sorted by

1

u/Scared-Owl-402 14h ago

Classic bug. The order that fixes it: create AppsflyerSdk(options), register the onDeepLinking listener, call initSdk with registerOnDeepLinkingCallback true, then runApp. keep it out of the widget tree entirely, main or a service that inits before the first frame. Test deferred with a real link click then a fresh install, not a debug run from the IDE

1

u/Sayuri_Feasby 14h ago

For ATT, the AppsFlyer options have timeToWaitForATTUserAuthorization, so the SDK holds the install event for a few seconds waiting on the prompt result. Set that, then show ATT inside that wait window instead of on splash before the SDK even exists