[英]on click launch whastapp from flutter app in IOS
我正在嘗試通過執行以下操作在點擊時啟動 WhatsApp:
var whatsAppUrl ="whatsapp://send?phone=+00000000";
await canLaunch(whatsAppUrl)? launch(whatsAppUrl):Scaffold.of(context).showSnackBar(new SnackBar(
content: new Text("You need WhatsApp to access"),
));
這在 android 中工作得非常好,但在 IOS 中沒有,我總是會在 IOS 中得到snackBar
我還嘗試將 url 更改為此 IOS:
whatsAppUrl = "https://api.whatsapp.com/send?phone=+00000";
但仍然沒有工作.. 我的 url 有什么問題?
在職的:
openWhatsApp() async {
var whatsAppUrl = "whatsapp://send?phone=+00000";
if (Platform.isIOS) {
if (await canLaunch('whatsapp://')) {
await launch(whatsAppUrl, forceSafariVC: false);
} else {
await launch(whatsAppUrl, forceSafariVC: true);
}
} else {
await canLaunch(whatsAppUrl)
? launch(whatsAppUrl)
: Scaffold.of(context).showSnackBar(
SnackBar(
content: new Text("You need WhatsApp to access Sara chatbot"),
),
);
}
}
似乎 url_launcher 前段時間有一些問題,如果你有最新版本,你應該能夠傳遞額外的參數 forceSafariVC 如果你想處理深度鏈接,應該在 ios 上設置為 false,我認為 canLaunch 應該只調用 url 方案前綴,就像這樣await canLaunch('whatsapp://')
嘗試在 ios/Runnes/info.plist 中添加權限:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>whatsapp</string>
</array>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.