[英]Flutter Dynamic Link triggers everytime I open app
I followed the guide below to set up dynamic links on my flutter project.我按照下面的指南在我的 flutter 项目上设置了动态链接。 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资料来源: Firebase-flutter-dynamic-links-step-by-step-guide
@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.我有同样的问题,它似乎来自我在 initState 中的调用。 I solved it by removing the observer after the dynamicLinkService call.我通过在 dynamicLinkService 调用后删除观察者来解决它。
I also have the didChangeAppLifecycleState method which is responsible for the Deeplink when the app is open.我还有 didChangeAppLifecycleState 方法,它在应用程序打开时负责 Deeplink。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.