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
220 stars 81 forks source link

uriLinkStream listener does not receive any events #170

Closed tylertzeyang closed 1 week ago

tylertzeyang commented 1 week ago

Describe the bug

The link is able to open my app, but the handling inside uriLinkStream listener is never hit after I've updated to the latest version (6.3.2).

void listenToDeepLinks() {
    logger.d("listenToDeepLinks() started");
    if (_streamSubscription != null) {
      _streamSubscription?.cancel();
    }
    if (!kIsWeb) {
      // It will handle app links while the app is already started - be it in
      // the foreground or in the background.
      _streamSubscription = _appLinks.uriLinkStream.listen((Uri? uri) {
        if (uri != null) {
          _handleDeepLink(uri);
        }
        logger.d('listenToDeepLinks() Received URI: $uri');
      }, onError: (Object err) {
        logger.e('listenToDeepLinks() Error occurred: $err');
      });
    }
  }

Does it related to

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

Does the example project work?

[/ ] Yes
[ ] No
[ ] 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, ...

[ ] Yes
[ ] No
[ /] Irrelevant here

BeezBeez commented 1 week ago

Hello ! I confirm I have the same problem on Windows. Custom URL Scheme is registered, my app window go back to foreground but the uri and stringLinkStream does not receive any events.

@tylertzeyang Does it was working for you on previous versions ?

tylertzeyang commented 1 week ago

Hello ! I confirm I have the same problem on Windows. Custom URL Scheme is registered, my app window go back to foreground but the uri and stringLinkStream does not receive any events.

@tylertzeyang Does it was working for you on previous versions ?

Yes it was working for me on previous version

tylertzeyang commented 1 week ago

I've found the root cause. It was due to the wrong implementation on _streamSubscription. It was being cancelled due to duplicate init on the stream.