r/appdev • • 19d 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.

3 Upvotes

5 comments sorted by

View all comments

1

u/Scared-Owl-402 19d 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/Aggressive-Wave-9782 18d ago

Thank you for giving the steps to fix it. Lemmi try it right away.