uni_links
uni_links copied to clipboard
getUriLinksStream().listen((Uri uri) invoked twice
Describe the bug getUriLinksStream().listen((Uri uri) { }, onError: (err) { }); } on PlatformException { // Handle exception by warning the user their action did not succeed // return? } this method is invoked twice everytime the app is being called by scheme I am using custom deep linking, not associated one..
To Reproduce Steps to reproduce the behavior:
- set up custom scheme
- calling scheme:// in webpage javascript: windows.location = "scheme://";
- code invoked twice
Expected behavior code invoked once should be expected
Smartphone (please complete the following information): iOS iphone XS Max simulator iOS 12
Additional context
my code snipset as below:
Future<Null> initUniLinks() async {
try {
String initialLink = await getInitialLink();
getUriLinksStream().listen((Uri uri) {
Map<String, String> query = uri.queryParameters;
Map<String, dynamic> json = jsonDecode(query['json']);
DeepLinkDao deepLinkDao = DeepLinkDao.fromJson(json);
handleDeepLink(deepLinkDao);
}, onError: (err) {
var a = 1;
var b = a + 1;
});
} on PlatformException {
// Handle exception by warning the user their action did not succeed
// return?
}
}
same thing on Android
Same here:
I ended up doing something like this with https://pub.dev/packages/synchronized:
// Attach a listener to catch any links when app is running in the background
_uniLinksSub = getUriLinksStream().listen((Uri uri) async {
await _previousUniUriLock.synchronized(() async {
if (_previousUniUri == uri) // this seems to be invoked twice so ignore the second one
_previousUniUri = null; // clear the uri here though so the user can manually invoke twice
else {
await processUri(uri);
_previousUniUri = uri;
}
});
}, onError: (err) {
print('uri stream error: $err');
});
Same here on iOS
Same here except it'll fire 4-5 times
any idea how resolve this case? same error here
I am stuck on this issue. For detail, the uriLinkStream.listen() the onData props returns twice the same URI.
uriLinkStream.listen((Uri? uri) async {
print('Deep link : $uri'); // I got twice comment here
});
Anyone has ideas or solutions for this issue!!
Any updates?
In my case I have an endless number of updates. It seems to depend on urls length and device, becouse i have links which was listen once. In my case phone is Huawei p20 pro.