Trying to add mailto - react native
Asked Answered
I

3

17

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>
Ilocano answered 7/2, 2017 at 19:24 Comment(0)
P
18

Link not work on Simulator.

React native linking mail api support subject, body?

Apple URL Scheme Reference

Persistence answered 8/2, 2017 at 1:54 Comment(1)
This is the original tutorial I followed. Strangely, it works on a physical device.Ilocano
C
15

Use this code :-

Linking.openURL(`mailto:${props.ArticleData.email}`)
Charismatic answered 7/9, 2018 at 11:27 Comment(0)
D
3

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])"
       />
Daria answered 8/2, 2017 at 2:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.