Any component / API in React Native to handle links by email and phone number

LinkingIOS says this:
* The iOS simulator does not support schemas mailto:

and tel:

 * because the Mail and Phone apps are not installed - you will need to test * them on the device.

What can I use in my React Native app to link to the native mail app when clicking on an email address? And in a similar way, how do I indicate the ability to call or text when clicking on a phone number?

+3


source to share


3 answers


You can use LinkingIOS.openURL (url). It will work great on iPhone. You cannot test it on the Simulator because these apps are not available on the simulator. So, use mailto: for e-mail, tel: for call and sms: for sending SMS.



I also recommend that you do feature detection with LinkingIOS.canOpenURL because iPad will not support call and sms features either. Therefore, it is always a good idea to check support for a URL scheme before using it.

+9


source


react-native-communications react very well to native npm module. which supports phone call, sms, email and urls.

Open a web address, easily call, send an email, text, iMessage (iOS only) someone from React Native



<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>

      

0


source


I found a third lib which was called react-native-autolink

https://github.com/joshswan/react-native-autolink

Hope this helps you.

0


source







All Articles