【发布时间】:2019-09-24 11:22:08
【问题描述】:
我正在尝试通过执行以下操作在点击时启动 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
如果它的 IOS,我也尝试将 url 更改为此:
whatsAppUrl = "https://api.whatsapp.com/send?phone=+00000";
但还是不行..我的网址有什么问题?
工作:
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"),
),
);
}
}
【问题讨论】: