简体   繁体   English

Flutter firebase 动态链接不听

[英]Flutter firebase dynamic link not listening

I am trying to implement Firebase Dynamic links in a flutter app.我正在尝试在 flutter 应用程序中实现 Firebase 动态链接。 When I click on the link it opens the app but doesn't call the listen functions.当我单击链接时,它会打开应用程序但不会调用监听函数。

I reconfigured step by step according to FlutterFire, so I don't think the issue is in configuration, but maybe in the way I'm using the plugin as there is no documentation on the last version of the plugin.我按照 FlutterFire 一步一步重新配置,所以我认为问题不在配置上,但可能是我使用插件的方式,因为没有关于插件最新版本的文档。

Firebase is correctly initialised in my app as I'm using other services. Firebase 在我使用其他服务时已在我的应用程序中正确初始化。

I'm doing tests on android simulator我在 android 模拟器上做测试

I'm trying to listen the dynamic link from a stateful widget with the following code我正在尝试使用以下代码收听来自有状态小部件的动态链接

I'm first navigating to the page containing this widget, then I background the app, I click on the link, the app opens at the same place and nothing happens.我首先导航到包含此小部件的页面,然后我将应用置于后台,单击链接,应用在同一个位置打开,但没有任何反应。

 @override void initState() { super.initState(); initLink(); } void initLink() { FirebaseDynamicLinks.instance.onLink.listen((dynamicLinkData) { print('dynamic link'); print(dynamicLinkData.toString()); // Navigator.pushNamed(context, dynamicLinkData.link.path); }).onError((error) { // Handle errors }); }

There is an open issue here https://github.com/FirebaseExtended/flutterfire/issues/8261 where a few others are having the same problem including myself.这里有一个未解决的问题https://github.com/FirebaseExtended/flutterfire/issues/8261其他一些人也有同样的问题,包括我自己。

It seems for now the temporary solution to at least getting things working again is posted by odlund.现在看来,至少让事情重新开始工作的临时解决方案是由 odlund 发布的。 If you make these changes the listener should work again until we have more of an official fix: https://github.com/FirebaseExtended/flutterfire/commit/8bb4bee7e678241e75ab37a2bcfa0831426b91fa如果您进行这些更改,监听器应该再次工作,直到我们有更多的官方修复: https://github.com/FirebaseExtended/flutterfire/commit/8bb4bee7e678241e75ab37a2bcfa0831426b91fa

Please update firebase_dynamic_links to 4.1.1.请更新firebase_dynamic_links到 4.1.1。 Seems to be an issue with the version 4.1.0 or earlier where FirebaseDynamicLinks.instance.onLink.listen doesn't work似乎是 4.1.0 或更早版本的问题,其中FirebaseDynamicLinks.instance.onLink.listen不起作用

You don't need to check if the app is in the background or resumed for this to work.您无需检查该应用程序是在后台运行还是已恢复运行。

This Works Perfectly!这非常有效!

class _MainAppState extends State<MainApp> {  

Future<void> initDynamicLinks() async {
    print("Initial DynamicLinks");
    FirebaseDynamicLinks dynamicLinks = FirebaseDynamicLinks.instance;

    // Incoming Links Listener
    dynamicLinks.onLink.listen((dynamicLinkData) {
      final Uri uri = dynamicLinkData.link;
      final queryParams = uri.queryParameters;
      if (queryParams.isNotEmpty) {
        print("Incoming Link :" + uri.toString());
        //  your code here
      } else {
        print("No Current Links");
        // your code here
      }
    });

    // Search for Firebase Dynamic Links
    PendingDynamicLinkData? data = await dynamicLinks
        .getDynamicLink(Uri.parse("https://yousite.page.link/refcode"));
    final Uri uri = data!.link;
    if (uri != null) {
      print("Found The Searched Link: " + uri.toString());
      // your code here
    } else {
      print("Search Link Not Found");
      // your code here
    }

  }

  Future<void> initFirebase() async {
    print("Initial Firebase");
    WidgetsFlutterBinding.ensureInitialized();
    await Firebase.initializeApp();
    // await Future.delayed(Duration(seconds: 3));
    initDynamicLinks();
  }

  @override
  initState() {
    print("INITSTATE to INITIALIZE FIREBASE");
    super.initState();
    initFirebase();
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter iOS Firebase 带链接值的动态链接推送命名页面 - Flutter iOS Firebase dynamic link push named page with the link value Flutter - Firebase 当应用处于终止模式时动态链接不工作 - Flutter - Firebase Dynamic Link not Working while app is in kill mode 从字符串输入中获取 Firebase 动态链接数据 url Flutter - Get Firebase Dynamic Link Data from String Input url Flutter flutter + firebase 无密码 email 登录-动态链接数据返回 null - flutter + firebase passwordless email login - dynamic link data returns null Flutter - Firebase 动态链接没有被onLink捕获但是在iOS上打开应用 - Flutter - Firebase Dynamic Link is not caught by onLink but open the app on iOS 深层链接/Firebase 动态链接 - Deeplinking/Firebase dynamic link 收不到firebase动态链接 - Not receiving firebase dynamic link Firebase 动态链接 - 取消缩短链接 - Firebase Dynamic Link - Unshorten the link 深度链接不包含有效的必需参数 - Flutter 和 Firebase 动态链接 - Deep Link does not contain valid required params - Flutter with Firebase Dynamic Link Flutter firebase 动态链接在应用程序上处理 url 时使用自定义参数自定义链接 - Flutter firebase dynamic links customise link with custom params when handling url on the app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM