avioli / uni_links

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

Initial Uri works, but listening to changes doesn't #165

Open igorcafe opened 1 year ago

igorcafe commented 1 year ago

I'm using custom scheme and am testing on my Android Emulator, which is running Android 9.

The getInitialUri is working as expected, but with uriLinkStream.listen nothing happens (no uri nor error). Which is strange because clicking on a link like that moves me to my app:

https://user-images.githubusercontent.com/85039990/211621098-7f494312-973b-4585-a2d6-b2c1689a059a.mp4

AndroidManifest.xml:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <!-- Accepts URIs that begin with abc://app.blabla.com -->
  <data
    android:scheme="[abc]"
    android:host="[app.blabla.com]" />
</intent-filter>

My initialization:

StreamSubscription? linkSubscription;
...
Future initUniLinks() async {  
  try {
    final uri = await getInitialUri();
    print("uri: $uri");

    linkSubscription = uriLinkStream.listen((Uri? uri) {
      print("uri: $uri");
    }, onError: (err) {
      print(err);
    });
  } on PlatformException {
    print("error!");
  }
}
igorcafe commented 1 year ago

Probably related to #162