avioli / uni_links

Flutter plugin for accepting incoming links.
BSD 2-Clause "Simplified" License
564 stars 317 forks source link

Initial Link Persistency on version 0.4.0 #71

Open annegreenwood opened 4 years ago

annegreenwood commented 4 years ago

Describe the bug If you use the example on pub.dev as your implementation structure, the variable initialLink is not set back to null on hot reload or any page rebuild, causing its value to persist even if you use setState to get it to be null again. This only happens in version 0.4.0, so I was able to get away with downgrading it, but I really like keeping my packages up to date and that behavior makes it not possible.

To Reproduce You can just use any function that deep links into your app. After you hot reload, variable initialLink persists the link that took you into the app instead of being set back to null.

Expected behavior The same as the previous versions, when you could deeplink into your app and get a clear the variable cleared from what you got in the variable link in the getLinksStream().listen((String link) function.

Smartphone (please complete the following information):

Additional context That's all, if you have trouble reproducing, let me know and I'll articulate better. This also might be an intended feature and not a bug, but honestly, I'd rather sort out my variables persistency myself and not have them imposed to me. Aside from that, I really like the work you've done with the plugin so far, thank you so much for your contribution to the community.

dwiprawira commented 4 years ago

Hi There, i also facing this issue. is there any work around to fix this?

annegreenwood commented 4 years ago

Hi There, i also facing this issue. is there any work around to fix this?

I have downgraded it to 0.2.0. Still functional, still compatible with Android and iOS releases, but possibly not for long. I couldn't find a workaround for it, sorry.

rohankandwal commented 3 years ago

Hi, same issue, I am listening for deep link in Home Screen.

I am using both getUriLinksStream()(when app is running or in background) and getInitialUri() (when app cold starts). In case I get URI, I am navigating to different screen.

Since getInitialUri() is persisting uri, redirection is always happening, if I go back to Home Screen. If I remove getInitialUri(), then there is no app redirection in case of cold boot.

Any idea on how to handle this case?

AzadCoder commented 3 years ago

I called getUriLinksStream in the login page. and with the uni link I'm going to the reset password page the problem is after reseting password when I come back to login and go to home page. and when I log out it go to login page and after that go to reset password again. Also I called _sub.cancel() in the dispose of login page.

guilhermedaldim commented 3 years ago

Version 0.2.0 is no longer functional. I have the same problem, initialLink is persistent.

@avioli any solution? I believe this started to happen after the last package update

Silfalion commented 3 years ago

Have this issue as well.

atullasrado commented 2 years ago

I had a similar issue to @rohankandwal and @AzadCoder

Going back to the docs, the documentation for initialLink methods state that

You should handle this very early in your app's life and handle it only once.

So while initialLink isn't cleared, by handling the link only once there shouldn't be any issues from processing the same link again.

I fixed my issue by setting a global var in my main.dart which gets set during app startup. Once I've handled the initial link I set the global to false so when I return to that widget the link doesn't get processed again.

Hope this helps.