【发布时间】:2020-10-23 05:59:41
【问题描述】:
在 Flutter 中通过 whatsapp 发送消息在 IOS 上不起作用。它在 Android 上运行良好,但在 IOS whatsapp 上没有启动。我尝试了 3 种不同的方法,但都没有成功。
在 Runner Info.plist 中
<key>LSApplicationQueriesSchemes</key>
<array>
<string>whatsapp</string>
</array>
1)首先我尝试了这种方式通过消息发送消息
var whatsappUrl = "whatsapp://send?phone=$phone&text=$message";
if (await canLaunch(whatsappUrl)) {
await launch(whatsappUrl);
} else {
throw 'Could not launch $whatsappUrl';
}
但它在启动whatsapp时给出了一个例外
2)我尝试的第二种方法是从这个link这个找到的,但是它给出了一个找不到页面的错误
String url() {
if (Platform.isIOS) {
return "whatsapp://wa.me/$phone/?text=${Uri.parse(message)}";
} else {
return "whatsapp://send? phone=$phone&text=${Uri.parse(message)}";
}
}
if (await canLaunch(url())) {
await launch(url());
} else {
throw 'Could not launch ${url()}';
}
3)上次我尝试调用whatsapp url
String message = 'Hi, I see your Ad on Yallamotor and I am interested in your car '+title;
if (Platform.isIOS) {
await launch("https://wa.me/${phone}?text=${Uri.parse(message)}");
}
但它会在 whatsapp 上出现错误,就像我们找不到您要查找的页面一样
【问题讨论】:
-
你检查电话号码了吗?它不应该包含特殊字符。
-
@LalKrishna 电话是 +9233645XXXX。你认为 + 是问题吗?
-
是的。它应该是:(国家代码)(数字)。前任。 9233645xxxx
标签: android ios flutter whatsapp flutter-dependencies