React Native Open Mail ios code example
Example 1: react native open email client
<Button onPress={() => Linking.openURL('mailto:[email protected]') }
title="[email protected]" />
With subject and body:
<Button onPress={() => Linking.openURL('mailto:[email protected]?subject=SendMail&body=Description') }
title="[email protected]" />
Example 2: react native not open mail app
The code works perfectly the problem was the iOS simulator,
it needs to be tested on a real device.
import {Linking} from 'react-native'
url = 'mailto:message:0';
handlePress(url);
handlePress(url) {
console.log('Trying to access url')
console.log(url)
Linking.canOpenURL(url).then(supported => {
if (!supported) {
console.tron.log('Can\'t handle url: ' + url)
} else {
return Linking.openURL(url)
}
}).catch(err => console.error('An error occurred', err))
}