Skip to content

Commit 6a22eae

Browse files
authored
docs(email): update (#446)
1 parent ec6d8a4 commit 6a22eae

1 file changed

Lines changed: 49 additions & 30 deletions

File tree

packages/email/README.md

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,64 @@
11
# @nativescript/Email
22

3+
## Contents
4+
* [Intro](#intro)
5+
* [Installation](#installation)
6+
* [Use @nativescript/email](#use-nativescriptemail)
7+
* [Check for availability](#check-for-availability)
8+
* [Compose an email](#compose-an-email)
9+
* [Usage with Angular](#usage-with-angular)
10+
* [API](#api)
11+
* [Functions](#functions)
12+
* [ComposeOptions](#composeoptions)
13+
* [Known issues](#known-issues)
14+
15+
## Intro
16+
17+
A plugin to compose an e-mail, have the user edit the draft manually and send it.
18+
19+
> **Note:** This plugin depends on the default mail app. If you want a fallback to a third party client app like Gmail or Outlook, then check for availability, and if not available use a solution like [the Social Share plugin](https://github.com/tjvantoll/nativescript-social-share).
20+
321
[npm-image]: https://img.shields.io/npm/v/nativescript-email.svg
422
[npm-url]: https://npmjs.org/package/nativescript-email
523
[downloads-image]: https://img.shields.io/npm/dm/nativescript-email.svg
624

725
[twitter-image]: https://img.shields.io/twitter/follow/eddyverbruggen.svg?style=social&label=Follow%20me
826
[twitter-url]: https://twitter.com/eddyverbruggen
927

10-
You can use this plugin to compose an e-mail, have the user edit the draft manually, and send it.
11-
12-
> **Note:** This plugin depends on the default mail app. If you want a fallback to a third party client app like Gmail or Outlook, then check for availability, and if not available use a solution like [the Social Share plugin](https://github.com/tjvantoll/nativescript-social-share).
13-
1428
## Installation
1529

30+
To install the plugin, run the following command in the root directory of your project:
31+
1632
```cli
1733
npm install @nativescript/email
1834
```
1935

20-
## Usage
21-
### Importing
22-
Once you've installed the plugin, the next step is to import it before using it.
23-
```ts
24-
import * as email from '@nativescript/email';
25-
// or
26-
import { compose } from '@nativescript/email';
27-
// or even
28-
import { compose as composeEmail } from '@nativescript/email';
29-
```
36+
## Use @nativescript/email
3037

31-
### Checking the availability
38+
### Check for availability
3239

33-
To check if the device has a mail app installed, call the `available` method.
40+
To check if the device has the Mail app installed, call the `available` method.
3441

3542
```ts
36-
email.available().then((avail: boolean) => {
43+
import { available() } from '@nativescript/email';
44+
45+
available().then((avail: boolean) => {
3746
console.log('Email available? ' + avail);
3847
});
3948
```
40-
### Composing an email
49+
### Compose an email
50+
4151
To compose an email, use the `compose` method.
4252

4353
```js
44-
// let's first create a File object
54+
import { compose } from '@nativescript/email';
55+
56+
// first create a File object
4557
import { knownFolders } from '@nativescript/core';
4658
var appPath = knownFolders.currentApp().path;
4759
var logoPath = appPath + '/res/telerik-logo.png';
4860

49-
email
50-
.compose({
61+
compose({
5162
subject: 'Yo',
5263
body: 'Hello <strong>dude</strong> :)',
5364
to: ['eddyverbruggen@gmail.com', 'to@person2.com'],
@@ -82,15 +93,19 @@ email
8293
| `available()` | `Promise<boolean>`| Checks for availability of a mail app.|
8394
| `compose(options: ComposeOptions)` | `Promise<boolean>` | Composes and sends a [ComposeOptions](#composeoptions) email.|
8495

85-
### Attachment
96+
### Usage with Angular
8697

87-
| Name | Type | Description |
98+
Check out [this tutorial (YouTube)](https://www.youtube.com/watch?v=fSnQb9-Gtdk) to learn how to use this plugin in a NativeScript-Angular app.
99+
100+
## API
101+
### Functions
102+
| Function | Return Type | Description |
88103
|------|------|-------------|
89-
| `fileName`| `string` | The name used for the attachment.<br>Example: fileName: 'Cute-Kitten.png'|
90-
| `path` | `string` | The to the file to be attached. |
91-
| `mimeType` | `string` | (`iOS-only`)Used to help the iOS device figure out how to send the file.Example:mimeType: 'image/png'|
104+
| `available()` | `Promise<boolean>`| Checks for availability of a mail app.|
105+
| `compose(options: ComposeOptions)` | `Promise<boolean>` | Composes and sends a [ComposeOptions](#composeoptions) email.|
92106

93107
### ComposeOptions
108+
94109
| Name | Type | Description |
95110
|------|------|-------------|
96111
| `subject`| `string`| _Optional_: The subject of the email.|
@@ -103,14 +118,18 @@ email
103118
| `iosViewController` | `any` | _Optional_: (`iOS-only`) iOS View Controller to open `compose` from.|
104119

105120

106-
## Usage with Angular
121+
#### Attachment
122+
123+
| Name | Type | Description |
124+
|------|------|-------------|
125+
| `fileName`| `string` | The name used for the attachment.<br>Example: fileName: 'Cute-Kitten.png'|
126+
| `path` | `string` | The to the file to be attached. |
127+
| `mimeType` | `string` | (`iOS-only`)Used to help the iOS device figure out how to send the file.Example:mimeType: 'image/png'|
107128

108-
Check out [this tutorial (YouTube)](https://www.youtube.com/watch?v=fSnQb9-Gtdk) to learn how to use this plugin in a NativeScript-Angular app.
109129

110130
## Known issues
111131

112-
On iOS you can't use the simulator to test the plugin because of an iOS limitation.
113-
To prevent a crash, this plugin returns `false` when `available` is invoked on the iOS simulator.
132+
- On iOS, you can't use the simulator to test the plugin because of an iOS limitation. To prevent a crash, this plugin returns `false` when `available` is invoked on the iOS simulator.
114133

115134
## License
116135

0 commit comments

Comments
 (0)