Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to add mailto - react native

Mailto appears to not be working. All that happens is that the icon appears to be pressed, but no action occurs. Shoots out this warning:

Warning

warning

Code

<TouchableHighlight onPress={() => Linking.openURL('mailto:[email protected]?subject=abcdefg&body=body')}>
                      <Icon style={styles.icons} size={SIZE} name='envelope'/> 
    </TouchableHighlight>
like image 442
user2026178 Avatar asked Feb 07 '17 19:02

user2026178


3 Answers

Link not work on Simulator.

React native linking mail api support subject, body?

Apple URL Scheme Reference

like image 69
liupeixin Avatar answered Sep 19 '22 14:09

liupeixin


Use this code :-

Linking.openURL(`mailto:${props.ArticleData.email}`)
like image 34
ManojK Avatar answered Sep 20 '22 14:09

ManojK


This solution wast tested on an android emulator with a GoogleApi system image:

enter image description here

After you have the emulator configured you can use something like you are using:

<TouchableHighlight onPress={() => Linking.openURL('mailto:[email protected]?subject=abcdefg&body=body')}>
      <Text>email1</Text>
</TouchableHighlight>

or

You can use a package like https://www.npmjs.com/package/react-native-autolink

       <AutoLink
         text="email2 (mailto:[email protected])"
       />
like image 43
Florin Dobre Avatar answered Sep 22 '22 14:09

Florin Dobre