fix: uni links failed to be invoked with --cm running on macOS

This commit is contained in:
Kingtous committed 2023-02-07 01:31:23 +08:00
1 parent b2afde4b27
commit 1426771ec9
3 files changed
+21 -5

No files matched your search

+13 -3
View File
@@ -1292,14 +1292,24 @@ Future<bool> initUniLinks() async {
}
}
StreamSubscription? listenUniLinks() {
if (!(Platform.isWindows || Platform.isMacOS)) {
/// Listen for uni links.
///
/// * handleByFlutter: Should uni links being handled by Flutter.
///
/// Returns a [StreamSubscription] which can listen the uni links.
StreamSubscription? listenUniLinks({handleByFlutter = true}) {
if (Platform.isLinux) {
return null;
}
final sub = uriLinkStream.listen((Uri? uri) {
debugPrint("A uri was received: $uri.");
if (uri != null) {
callUniLinksUriHandler(uri);
if (handleByFlutter) {
callUniLinksUriHandler(uri);
} else {
bind.sendUrlScheme(url: uri.toString());
}
} else {
print("uni listen error: uri is empty.");
}