我正在尝试创建一个链接,以便从我的react原生应用程序在whatsapp上开始对话,但Linking.canOpenURL()方法总是返回false……
我的代码如下:
const url = `whatsapp://send?phone=${celNumber}`;
Linking.canOpenURL(url).then(supported => {
if (supported) {
Linking.openURL(url);
} else {
Alert.alert(
'Alert',
'WhatsApp is not installed',
)
}
});如果我尝试放入像tel:${celNumber}这样的其他url,它会返回true,所以我认为whatsapp url和canOpenURL()有一些问题,因为whatsapp url使用Linking.openURL()方法...
发布于 2018-03-11 04:35:12
我想你是在用iOS吧?然后你必须在你的Info.plist文件LSApplicationQueriesSchemes中声明网址的方案'whatsapp‘。
iOS9: canOpenURL returning false for WhatApp's url scheme
https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl
https://stackoverflow.com/questions/49210944
复制相似问题