简体   繁体   English

Flutter 每次打开应用程序时都会触发动态链接

[英]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.

相关问题 Flutter - Firebase 动态链接没有被onLink捕获但是在iOS上打开应用 - Flutter - Firebase Dynamic Link is not caught by onLink but open the app on iOS 我的 flutter iOS 应用程序尚未发布。 如果应用程序尚未安装,我如何知道我的 firebase 动态链接可以打开 Appstore? - My flutter iOS app hasn't been released yet. How can I know my firebase dynamic link works to open Appstore if the app isn't installed yet? Flutter - Firebase 当应用处于终止模式时动态链接不工作 - Flutter - Firebase Dynamic Link not Working while app is in kill mode 从深度链接或动态返回数据到 Flutter App - Return Data from Deep Link or Dynamic to Flutter App Flutter firebase 动态链接不听 - Flutter firebase dynamic link not listening 当应用程序已经打开时从动态链接中提取数据 - Flutter - Extract Data from Dynamic Link When App is already opened- Flutter Flutter firebase 动态链接在应用程序上处理 url 时使用自定义参数自定义链接 - Flutter firebase dynamic links customise link with custom params when handling url on the app Flutter Firebase - 如何在点击 Firebase 发送的 email 验证链接时打开应用程序? - Flutter Firebase - How to open the app when tapping on email verification link send by Firebase? 通过 Safari 打开时,Firebase 动态链接不会重定向到应用程序 - Firebase Dynamic Link doesn't redirect to the app when open through Safari Firebase 通过 Chrome 打开时,动态链接不会重定向到应用程序 - Firebase Dynamic Link doesn't redirect to the app when open through Chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM