admin管理员组文章数量:1356851
I'm trying to create a link to start a conversation on whatsapp from my react native app, but the method Linking.canOpenURL() is allways retuning false...
My code is the following:
const url = `whatsapp://send?phone=${celNumber}`;
Linking.canOpenURL(url).then(supported => {
if (supported) {
Linking.openURL(url);
} else {
Alert.alert(
'Alert',
'WhatsApp is not installed',
)
}
});
If I try to put some other url like tel:${celNumber}
it returns true, so I think there is some problem with whatsapp url and canOpenURL(), since the whatsapp url works with the method Linking.openURL()...
I'm trying to create a link to start a conversation on whatsapp from my react native app, but the method Linking.canOpenURL() is allways retuning false...
My code is the following:
const url = `whatsapp://send?phone=${celNumber}`;
Linking.canOpenURL(url).then(supported => {
if (supported) {
Linking.openURL(url);
} else {
Alert.alert(
'Alert',
'WhatsApp is not installed',
)
}
});
If I try to put some other url like tel:${celNumber}
it returns true, so I think there is some problem with whatsapp url and canOpenURL(), since the whatsapp url works with the method Linking.openURL()...
2 Answers
Reset to default 2I quess you are using iOS? Then you have to declared the URL’s scheme 'whatsapp' in your Info.plist file LSApplicationQueriesSchemes.
iOS9: canOpenURL returning false for WhatApp's url scheme
https://developer.apple./documentation/uikit/uiapplication/1622952-canopenurl
if lands there someone doing it with expo in 2024, here're the relevant expo doc (and ref).
Copying the example app.json
config from the doc:
{
"expo": {
"ios": {
"infoPlist": {
"LSApplicationQueriesSchemes": ["whatsapp"]
}
}
}
}
本文标签: javascriptReact Native LinkingcanOpenURL() with WhatsApp callStack Overflow
版权声明:本文标题:javascript - React Native Linking.canOpenURL() with WhatsApp call - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743971994a2570727.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论