diff --git a/README.md b/README.md index 2879936..f0d9597 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,23 @@ A React Native wrapper for Apple's ``MFMailComposeViewController`` from iOS and Mail Intent on android Supports emails with attachments. -### Installation +## Installation There was a breaking change in RN >=40. So for React Native >= 0.40: use v3.x and higher of this lib. otherwise use v2.x ```bash -npm i --save react-native-mail +npm i --save react-native-mail # npm syntax +yarn add react-native-mail # yarn syntax ``` -### Add it to your android project +### Automatic Installation +You can automatically link the native components or follow the manual instructions below if you prefer. + + ```bash + react-native link + ``` + +### Manual Installation: Android * In `android/setting.gradle` @@ -85,7 +93,7 @@ public class MainApplication extends Application implements ReactApplication { -### Add it to your iOS project +### Manual Installation: iOS 1. Run `npm install react-native-mail --save` 2. Open your project in XCode, right click on `Libraries` and click `Add @@ -97,16 +105,25 @@ public class MainApplication extends Application implements ReactApplication { ## Example ```javascript -var Mailer = require('react-native-mail'); +/** + * Sample React Native App + * https://github.com/facebook/react-native + * @flow + */ + +import React, { Component } from 'react'; +import { View, Alert, Button } from 'react-native'; +import Mailer from 'react-native-mail'; -var MailExampleApp = React.createClass({ - handleHelp: function() { +export default class App extends Component { + + handleEmail = () => { Mailer.mail({ subject: 'need help', recipients: ['support@example.com'], ccRecipients: ['supportCC@example.com'], bccRecipients: ['supportBCC@example.com'], - body: '', + body: 'A Bold Body', isHTML: true, attachment: { path: '', // The absolute path of the file from which to read data. @@ -114,23 +131,33 @@ var MailExampleApp = React.createClass({ name: '', // Optional: Custom filename for attachment } }, (error, event) => { - if(error) { - AlertIOS.alert('Error', 'Could not send mail. Please send a mail to support@example.com'); - } + Alert.alert( + error, + event, + [ + {text: 'Ok', onPress: () => console.log('OK: Email Error Response')}, + {text: 'Cancel', onPress: () => console.log('CANCEL: Email Error Response')} + ], + { cancelable: true } + ) }); - }, - render: function() { + } + + render() { return ( - - - - - + +