Ahm*_*Ali 13 whatsapp reactjs react-native
我正在尝试从反应原生的应用程序向WhatsApp联系人发送短信,我发现我可以通过链接来实现
Linking.openURL('whatsapp://send?text=hello');
Run Code Online (Sandbox Code Playgroud)
上面的代码只打开什么应用程序,我需要打开一个特定号码的聊天是否有一个参数我必须像文字一样发送?!
Mah*_*oud 26
您可以使用它将消息发送到特定号码:
Linking.openURL('whatsapp://send?text=hello&phone=xxxxxxxxxxxxx')
将消息分享到 Whatsapp 到独立于平台的特定预定义号码
sendWhatsApp = () => {
let msg = "type something";
let phoneWithCountryCode = "xxxxxxxxxx";
let mobile =
Platform.OS == "ios" ? phoneWithCountryCode : "+" + phoneWithCountryCode;
if (mobile) {
if (msg) {
let url = "whatsapp://send?text=" + msg + "&phone=" + mobile;
Linking.openURL(url)
.then(data => {
console.log("WhatsApp Opened");
})
.catch(() => {
alert("Make sure WhatsApp installed on your device");
});
} else {
alert("Please insert message to send");
}
} else {
alert("Please insert mobile no");
}
};
Run Code Online (Sandbox Code Playgroud)
请注意:如果在 Android 中打开,请在带有国家/地区的手机前面发送 +
归档时间: |
|
查看次数: |
9710 次 |
最近记录: |