我无法在颤振的网络视图中打开Telegram,WhatsApp,Facebook,Twitter链接?



我创建了一个Flutter网络视图应用程序。。。我的申请中有股票期权。当我点击WhatsApp共享时,它不会导航到外部whats应用。它正在进入找不到的页面。我想打开一个外部应用程序。如何处理这项任务,以支持安卓系统?我使用flutter webview插件启动了一个URL。我的flutter webview版本2.3.1

简而言之,这样做可能会对您有所帮助:

import 'package:webview_flutter/webview_flutter.dart';
import 'package:url_launcher/url_launcher.dart'; 
// ...
WebView(
initialUrl: 'https://example.com',
navigationDelegate: (NavigationRequest request) {
if (request.url.contains("mailto:")) {
canLaunchUrl(Uri(
scheme: 'mailto', path: 'you@example.com'))
.then((bool result) {
launchUrl(
Uri(scheme: 'mailto', path: 'you@example.com'),
mode: LaunchMode.externalApplication,
);
});
return NavigationDecision.prevent;
} else if (request.url.contains("tg:")) { // TELEGRAM
canLaunchUrl(
Uri(scheme: 'tg', path: 'resolve?domain=YourId'))
.then((bool result) {
launchUrl(
Uri(scheme: 'tg', path: 'resolve?domain=YourId'),
mode: LaunchMode.externalApplication,
);
});
return NavigationDecision.prevent;
}
return NavigationDecision.navigate;
},
),
// ...

Html链接:

<a href="tg:resolve?domain=YourId">Telegram (YourId)</a>
<a href="mailto:you@example.com">Email (you@example.com)</a>

最新更新