Reputation: 675
I receive a firebase dynamic link in initState.
This works great if the app is completely off. But if the app was running before clicking the link, initState is not called again, thus the dynamiclink is not processed.
Should I try to process the firebase dynamic link through WidgetsBindingObserver (for a similar effect to onResume in Android)? If not, what would be the proper way?
Upvotes: 7
Views: 3782
Reputation: 6029
Just like .getInitialLink()
there is an onLink() listener now.
FirebaseDynamicLinks.instance.onLink(
onSuccess: (PendingDynamicLinkData dynamicLink) async {
final Uri deepLink = dynamicLink?.link;
if (deepLink != null) {
// Process your deeplink
}
},
onError: (OnLinkErrorException e) async {}
);
Upvotes: 0
Reputation: 103461
I had the same problem and I solved using WidgetsBindingObserver
to listen when the app is foreground, but I found an issue on iOS.
I wrote a post about it, you can check it:
https://medium.com/@diegoveloper/flutter-firebase-dynamic-link-6f1b79278ce0
Upvotes: 2