Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase dynamic links handled twice

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?

like image 806
diidu Avatar asked Jun 06 '16 08:06

diidu


1 Answers

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).

like image 159
I. Trogrlic Avatar answered Oct 19 '22 23:10

I. Trogrlic