Reputation: 825
In my flutter app I'm using the firebase dynamic links plugin.
In the main function the retrieveDynamicLink
is called and the link is handled, as well as every time the app is resumed a lifecycle listener calls retrieveDynamicLink
again and handles the link.
The plugin calls the android method: getDynamicLink(registrar.activity().getIntent())
, and the documentation states that this method should clean the intent to make any other call return null until the app is open/resumed from another link.
But that's not what is happening, not always at least.
If I open the app from a dynamic link, switch to another app, and then go back to the app, the retrieveDynamicLink
call returns the link again.
If I originally open the app from its icon that does not happen.
Does anyone have any suggestion?
I'm using firebase_dynamic_links: ^0.1.0+1
on Flutter 0.11.7
Upvotes: 2
Views: 1917
Reputation: 411
Not a proper solution, but I noticed that adding a delay between the resume event and actually getting the dynamic link seems to solve the problem.
Might be useful as a temporary workaround.
I'm using 500ms.
Must be some kind of race condition involved.
The iOS implementation actually suffered from the same (similar) issue before: https://medium.com/@diegoveloper/flutter-firebase-dynamic-link-6f1b79278ce0
Example code exists in the link.
But basically:
if (state == AppLifecycleState.resumed) {
_timerLink = new Timer(const Duration(milliseconds: 500), () {
_retrieveDynamicLink();
});
}
EDIT: Just noticed that @diegoveloper is the creator of both the article + workaround + the iOS fix and the new Android flutter plugin bug report. So, thank you!
Upvotes: 0
Reputation: 103461
I've already fixed the issue on my repo, could you try using this config in pubspec.yaml
:
firebase_dynamic_links:
git:
url: https://github.com/diegoveloper/plugins
path: packages/firebase_dynamic_links
Let me know if it works
Upvotes: 1