llfbandit / app_links

Android App Links, Deep Links, iOs Universal Links and Custom URL schemes handler for Flutter.
https://pub.dev/packages/app_links
Apache License 2.0
176 stars 68 forks source link

Using the app links in different screens in the app #44

Closed Djihanegh closed 1 year ago

Djihanegh commented 1 year ago

Describe the bug

I want to use the deep links in the Login Screen and the universal Links inside the app ( Home screen for example ) The deep links in the login screen were working fine, but once i added another instance of AppLinks in Home Screen, the listeners seems not working as before

i receive the URI in the console :

handleIntent: (Action) android.intent.action.VIEW handleIntent: (Data) https://XXXXX/...................

But the method listen it doesn't dispatch the message received ( it listens only the first time or when i rerun the project ) :

// Handle link when app is in warm state (front or background)

    _linkSubscription = _appLinks.allUriLinkStream.listen((uri) {
      if (kDebugMode) {
        log('[Login] onAppLink: $uri');
      }
      openAppLink(uri);
    });

A clear and concise description of what the bug is.

Does it related to

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

Does the example project work?

[ ] Yes
[ ] No
[x] Irrelevant here

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

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

[x] Yes
[ ] No
[ ] Irrelevant here

llfbandit commented 1 year ago

This is hard to tell without a reproducer. Does the behaviour stay the same if you remove the first instance on your login screen?

In most cases, you should not tie deeplinking to a widget/screen but instead have a single instance in your app to allow handling links from everywhere in your app by calling navigation router for example or any service needed to handle the incoming link. You can have a look at the example provided with the package for inspiration.

ankitmundada commented 1 year ago

@llfbandit

Is there a particular reason as to why we should not use multiple AppLinks() instances?

There are definite use cases of this.