Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript React Native中处理电子邮件和电话号码链接的任何组件/API_Javascript_Ios_React Native - Fatal编程技术网

Javascript React Native中处理电子邮件和电话号码链接的任何组件/API

Javascript React Native中处理电子邮件和电话号码链接的任何组件/API,javascript,ios,react-native,Javascript,Ios,React Native,林金戈斯说: *iOS模拟器不支持mailto:和tel:模式 *因为邮件和电话应用程序未安装-您需要进行测试 *把它们放在设备上 单击电子邮件地址时,我可以在React Native应用程序中使用什么链接到Native Mail应用程序?同样地,当点击电话号码时,我如何提供呼叫或短信选项?您可以使用LinkingIOS.openURL(url)。它将在实际的iPhone上完美工作。您无法在模拟器上测试它,因为这些应用程序在模拟器上不可用。因此,使用mailto:发送电子邮件,使用tel:拨打电

林金戈斯说:
*iOS模拟器不支持
mailto:
tel:
模式 *因为邮件和电话应用程序未安装-您需要进行测试 *把它们放在设备上


单击电子邮件地址时,我可以在React Native应用程序中使用什么链接到Native Mail应用程序?同样地,当点击电话号码时,我如何提供呼叫或短信选项?

您可以使用LinkingIOS.openURL(url)。它将在实际的iPhone上完美工作。您无法在模拟器上测试它,因为这些应用程序在模拟器上不可用。因此,使用mailto:发送电子邮件,使用tel:拨打电话,使用sms:发送短信

我还建议您使用LinkingIOS.canOpenURL进行功能检测,因为iPad也不支持通话和短信功能。因此,在使用url方案之前,最好先检查它的支持情况。

非常好的本地npm模块。它支持电话、短信、电子邮件和URL

打开网址、轻松拨打电话、发送电子邮件、发送文本和iMessage(仅限iOS) 有人是土生土长的


通讯。电话呼叫('0123456789',正确)}>
打电话
Communications.email(['emailAddress1','emailAddress2',null,null,'My Subject','My body text')}>
发送电子邮件
Communications.text('0123456789')}>
发送文本/i消息
通信网https://github.com/facebook/react-native')}>
在Github上打开react本机repo

我找到了第三个lib,名为
react native autolink


希望这能对您有所帮助

也许我没有正确理解您,但您应该使用
LinkingIOS.openURL(url)
方法。唯一需要记住的是,你不能在模拟器上测试,但它应该在真实设备上按预期工作。苹果URL方案参考,
<View style={styles.container}>
        <TouchableOpacity onPress={() => Communications.phonecall('0123456789', true)}>
          <View style={styles.holder}>
            <Text style={styles.text}>Make phonecall</Text>
          </View>
        </TouchableOpacity>
        <TouchableOpacity onPress={() => Communications.email(['emailAddress1', 'emailAddress2'],null,null,'My Subject','My body text')}>
          <View style={styles.holder}>
            <Text style={styles.text}>Send an email</Text>
          </View>
        </TouchableOpacity>
        <TouchableOpacity onPress={() => Communications.text('0123456789')}>
          <View style={styles.holder}>
            <Text style={styles.text}>Send a text/iMessage</Text>
          </View>
        </TouchableOpacity>
        <TouchableOpacity onPress={() => Communications.web('https://github.com/facebook/react-native')}>
          <View style={styles.holder}>
            <Text style={styles.text}>Open react-native repo on Github</Text>
          </View>
        </TouchableOpacity>
      </View>