单击 IOS 中的 flutter 应用程序启动 whastapp
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"),
),
);
}
}
尝试在 ios/Runnes/info.plist:
中添加权限
<key>LSApplicationQueriesSchemes</key>
<array>
<string>whatsapp</string>
</array>
前段时间 url_launcher 似乎有一些问题,如果你有最新版本,你应该能够传递额外的参数 forceSafariVC 应该在 ios 上设置为 false如果你想处理深层链接,我也认为 canLaunch 应该只调用 url 方案前缀,就像这样 await canLaunch('whatsapp://')
我正在尝试通过点击启动 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"),
),
);
}
}
尝试在 ios/Runnes/info.plist:
中添加权限<key>LSApplicationQueriesSchemes</key>
<array>
<string>whatsapp</string>
</array>
前段时间 url_launcher 似乎有一些问题,如果你有最新版本,你应该能够传递额外的参数 forceSafariVC 应该在 ios 上设置为 false如果你想处理深层链接,我也认为 canLaunch 应该只调用 url 方案前缀,就像这样 await canLaunch('whatsapp://')