Firebase动态链接处理了两次 [英] Firebase dynamic links handled twice

查看:109
本文介绍了Firebase动态链接处理了两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,当Android应用程序重新启动时,Firebase动态链接将重新启动。以下序列会产生问题:


  1. 点击深层链接URL

  2. (如预期)

  3. 关闭应用程序(完全)

  4. 从图标打开应用程序

  5. 应用程序在深层链接指向的视图处打开(即使不应该)
  6. 之后,它可以正常工作

我正在使用最新的(9.0.2)库。代码几乎和示例中一样(例如: https://firebase.google.com/docs/dynamic-links/android#add-an-intent-filter-for-deep-links ),autoLaunchDeepLink为false。




  • 我注意到有一个引起这个问题的错误,但是应该在当前版本中修正:
    https://github.com/googlesamples/google-services/issues/141


  • 通过调用AppInvite.AppInviteApi.getInvitation两次,按照github错误报告中的指示,尝试了一种解决方法。没有成功。

  • 在onCreate中,我正在检查savedInstance是否为null,只有在深层链接的情况下才检查。


  • 我也在onNewIntent中检查深层链接,以便在应用程序运行时处理它,但是当发生问题时不会调用它。 >

    在我的清单中,具有特定协议和主机的意图过滤器仅包含在主要活动中。该协议也用于其他活动中的其他过滤器,但我也试图在那些没有效果的使用不同的协议。只有主要活动使用AppInvite.AppInviteApi.getInvitation获取意图。即使我从所有活动中删除其他意图过滤器也会出现问题。




任何想法可能是错误的或我还应该检查吗?

解决方案

您需要调用 getInvitation()在您的启动器活动中,以及您声明处理动态链接的活动中。但是在处理动态链接的活动中,您需要传递 null ,而不是传递活动作为<$ c $的第二个参数c> getInvitation(),
像这样 AppInvite.AppInviteApi.getInvitation(mGoogleApiClient,null,autoLaunchDeepLink)


I have a problem that firebase dynamic link is relaunched when the android app is restarted. The following sequence produces the problem:

  1. click the deep link URL
  2. the app is opened at the view pointed by the deep link (as expected)
  3. close the app (completely)
  4. open the app from the icon
  5. the app is opened at the view pointed by the deep link (even though it should not)
  6. after that it works fine

I am using the latest (9.0.2) libraries. The code is pretty much as in the examples (e.g. here: https://firebase.google.com/docs/dynamic-links/android#add-an-intent-filter-for-deep-links), autoLaunchDeepLink being false.

  • I noticed that there has been a bug causing this, but it should be fixed in the current release: https://github.com/googlesamples/google-services/issues/141

  • I tried a workaround by calling AppInvite.AppInviteApi.getInvitation twice, as instructed in github error report. No success.

  • In onCreate I am checking that savedInstance is null and checking deep link only if it is.

  • I am checking deep link also in onNewIntent in order to handle it while the app is running, however this is not called when the problem occurs.

  • In my manifest, the intent-filter with the specific protocol and host are included only in the main activity. The protocol is used also in other filters in other activities, but I tried also using different protocol in those with no effect. Only the main activity uses AppInvite.AppInviteApi.getInvitation to get the intent. The problem occurs even if I remove other intent filters from all activities.

Any ideas what could be wrong or what I should still check?

解决方案

You need to call getInvitation() both in your launcher activity, and in the activity which you declared to handle the dynamic link.

But in the activity which handles the dynamic link, you need to pass null instead of passing the activity as second parameter of getInvitation(), like this AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, null, autoLaunchDeepLink).

这篇关于Firebase动态链接处理了两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆