Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlapping Subscriptions on appLinks.uriLinkStream Across Multiple Screens #165

Open
Splagov opened this issue Oct 16, 2024 · 2 comments
Open

Comments

@Splagov
Copy link

Splagov commented Oct 16, 2024

Describe the bug

I’m facing a problem when trying to subscribe to appLinks.uriLinkStream on multiple screens in a Flutter app. The use case requires handling deep links on both the initial screen and another subsequent screen. The flow looks like this:

  1. On the initial screen, I subscribe to uriLinkStream to parse and handle a deep link.
  2. After parsing and handling on the first screen, I navigate to the second screen, where I also subscribe to uriLinkStream to handle the same link but in a different way.
  3. However, while the deep link handler on the first screen works, the handler on the second screen does not trigger, even though I am using a similar subscription setup.

Key Observations:

  • If I subscribe to uriLinkStream twice within the same screen (in the same State file), both subscriptions work, and both handlers trigger.
  • But when subscribing to the stream on two different screens, only the handler on the first screen is triggered, while the second screen doesn't respond to the deep link.

Code Example:
_subscription = appLinks.uriLinkStream.listen((uri) { deepLinkHandler.handleDeepLink(uri); });

Use Case:
I need to handle the deep link differently on two screens:
On the initial screen, I process the deep link and extract some metadata.
On the second screen, after fetching additional data from the network, I want to handle the same deep link again but in a different way.
It seems like the uriLinkStream is not designed to handle multiple subscriptions across different screens, especially when navigation is involved. However, multiple subscriptions in a single screen work as expected.

Any suggestions on how to properly manage deep link subscriptions across multiple screens would be helpful!

Does it related to

[ ] App Links (Android)
[ ] Deep Links (Android)
[ ] Universal Links (iOS)
[ ] or Custom URL schemes? (iOS)
[X] Custom URL schemes? (iOS and Android)

Does the example project work?

[X ] Yes
[ ] No
[ ] Irrelevant here

Did you fully read the instructions for the targeted platform before submitting this issue?
yes

Uploaded your files to webserver, HTTPS, direct connection, scheme pattern setup, ...

[ ] Yes
[ ] No
[X ] Irrelevant here

@Splagov
Copy link
Author

Splagov commented Oct 16, 2024

is it bcz second listener subscribed after event occurred?
In order to trigger both listeners, they must be subscribed on the moment of the event?

@llfbandit
Copy link
Owner

Sorry for the late reply.
Navigation should not be conflicting with streams.

Yes, your second subscription must be done before handling further events. There's no replay.
There's only a special case when first subscribing to the stream to retrieve the very first event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants