首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用WhatsApp调用反应本机Linking.canOpenURL()

使用WhatsApp调用反应本机Linking.canOpenURL()
EN

Stack Overflow用户
提问于 2018-03-10 23:45:19
回答 1查看 9.5K关注 0票数 7

我正在尝试创建一个链接,以便从我的react原生应用程序在whatsapp上开始对话,但Linking.canOpenURL()方法总是返回false……

我的代码如下:

代码语言:javascript
复制
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()方法...

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49210944

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档