Reputation: 172
I followed the guide below to set up dynamic links on my flutter project. The dynamic link works and takes me to the desire location in the app but the issue is that everytime I reopen the app, the dynamic link is triggered again. The code block below is what triggers the link when the app is resumed. What do I have to do for the app to know that if the link is not being clicked, dont take me to the dynamics link location?
@override
void didChangeAppLifecycleState(AppLifecycleState state) async{
if (state == AppLifecycleState.resumed) {
_timerLink = new Timer(
const Duration(milliseconds: 1000),
() {
_dynamicLinkService.retrieveDynamicLink(context);
},
);
}
}
Source: Firebase-flutter-dynamic-links-step-by-step-guide
Upvotes: 1
Views: 1293
Reputation: 11
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
//calls the link on app, from app closed
_dynamicLinkService.initDynamicLinks(context);
WidgetsBinding.instance.removeObserver(this);
}
I had the same problem, it seemed to be coming from my call in initState though. I solved it by removing the observer after the dynamicLinkService call.
I also have the didChangeAppLifecycleState method which is responsible for the Deeplink when the app is open.
Upvotes: 1