A react-native wrapper on top of apple's MFMailComposeViewController.
- Run
npm install react-native-mail --save - Open your project in XCode, right click on
Librariesand clickAdd Files to "Your Project Name"(Screenshot) then (Screenshot). - Add
libRNMail.atoBuild Phases -> Link Binary With Libraries(Screenshot). - Whenever you want to use it within React code now you can:
var Mailer = require('NativeModules').RNMail;
var Mailer = require('NativeModules').RNMail;
var MailExampleApp = React.createClass({
handleHelp: function() {
Mailer.mail({
subject: 'need help',
recipients: ['support@example.com'],
body: ''
}, (error, event) => {
if(error) {
AlertIOS.alert('Error', 'Could not send mail. Please send a mail to support@example.com');
}
});
},
render: function() {
return (
<TouchableHighlight
onPress={row.handleHelp}
underlayColor="#f7f7f7">
<View style={styles.container}>
<Image source={require('image!announcement')} style={styles.image} />
</View>
</TouchableHighlight>
);
}
});