Trying to add mailto - react native
26,787
Solution 1
Link not work on Simulator.
React native linking mail api support subject, body?
Solution 2
Use this code :-
Linking.openURL(`mailto:${props.ArticleData.email}`)
Solution 3
This solution wast tested on an android emulator with a GoogleApi system image:
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])"
/>
Author by
user2026178
Updated on July 05, 2022Comments
-
user2026178 over 1 year
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
Code
<TouchableHighlight onPress={() => Linking.openURL('mailto:[email protected]?subject=abcdefg&body=body')}> <Icon style={styles.icons} size={SIZE} name='envelope'/> </TouchableHighlight>
-
user2026178 almost 7 yearsThis is the original tutorial I followed. Strangely, it works on a physical device.