capacitor-email-composer
Advanced tools
Comparing version 1.1.3 to 1.2.0
@@ -182,7 +182,86 @@ { | ||
], | ||
"docs": "indicats if the body is HTML or plain text (primarily iOS)", | ||
"docs": "indicates if the body is HTML or plain text (primarily iOS)", | ||
"complexTypes": [], | ||
"type": "boolean | undefined" | ||
}, | ||
{ | ||
"name": "attachments", | ||
"tags": [ | ||
{ | ||
"text": [ | ||
{ | ||
"text": "1.2.0", | ||
"kind": "text" | ||
} | ||
], | ||
"name": "since" | ||
} | ||
], | ||
"docs": "attachments that are added to the mail\nfile paths or base64 data streams", | ||
"complexTypes": [ | ||
"Attachment" | ||
], | ||
"type": "Attachment[] | undefined" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Attachment", | ||
"slug": "attachment", | ||
"docs": "", | ||
"tags": [], | ||
"methods": [], | ||
"properties": [ | ||
{ | ||
"name": "path", | ||
"tags": [ | ||
{ | ||
"text": [ | ||
{ | ||
"text": "1.2.0", | ||
"kind": "text" | ||
} | ||
], | ||
"name": "since" | ||
} | ||
], | ||
"docs": "The path of the attachment. See the docs for explained informations.", | ||
"complexTypes": [], | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "type", | ||
"tags": [ | ||
{ | ||
"text": [ | ||
{ | ||
"text": "1.2.0", | ||
"kind": "text" | ||
} | ||
], | ||
"name": "since" | ||
} | ||
], | ||
"docs": "The type of the attachment. See the docs for explained informations.", | ||
"complexTypes": [], | ||
"type": "'absolute' | 'resource' | 'asset' | 'base64'" | ||
}, | ||
{ | ||
"name": "name", | ||
"tags": [ | ||
{ | ||
"text": [ | ||
{ | ||
"text": "1.2.0", | ||
"kind": "text" | ||
} | ||
], | ||
"name": "since" | ||
} | ||
], | ||
"docs": "The name of the attachment. See the docs for explained informations.\n\nRequired for base64 attachements.", | ||
"complexTypes": [], | ||
"type": "string | undefined" | ||
} | ||
] | ||
} | ||
@@ -189,0 +268,0 @@ ], |
@@ -52,3 +52,3 @@ export interface EmailComposerPlugin { | ||
/** | ||
* indicats if the body is HTML or plain text (primarily iOS) | ||
* indicates if the body is HTML or plain text (primarily iOS) | ||
* | ||
@@ -58,2 +58,31 @@ * @since 1.0.1 | ||
isHtml?: boolean; | ||
/** | ||
* attachments that are added to the mail | ||
* file paths or base64 data streams | ||
* | ||
* @since 1.2.0 | ||
*/ | ||
attachments?: Attachment[]; | ||
} | ||
export interface Attachment { | ||
/** | ||
* The path of the attachment. See the docs for explained informations. | ||
* | ||
* @since 1.2.0 | ||
*/ | ||
path: string; | ||
/** | ||
* The type of the attachment. See the docs for explained informations. | ||
* | ||
* @since 1.2.0 | ||
*/ | ||
type: 'absolute' | 'resource' | 'asset' | 'base64'; | ||
/** | ||
* The name of the attachment. See the docs for explained informations. | ||
* | ||
* Required for base64 attachements. | ||
* | ||
* @since 1.2.0 | ||
*/ | ||
name?: string; | ||
} |
{ | ||
"name": "capacitor-email-composer", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "E-Mail Composer Plugin for Capacitor", | ||
@@ -48,6 +48,7 @@ "main": "dist/plugin.cjs.js", | ||
"devDependencies": { | ||
"@capacitor/android": "^3.0.0", | ||
"@capacitor/core": "^3.0.0", | ||
"@capacitor/cli": "4.1.0", | ||
"@capacitor/android": "4.1.0", | ||
"@capacitor/core": "4.1.0", | ||
"@capacitor/docgen": "0.0.16", | ||
"@capacitor/ios": "^3.0.0", | ||
"@capacitor/ios": "4.1.0", | ||
"@ionic/eslint-config": "^0.3.0", | ||
@@ -72,3 +73,3 @@ "@ionic/prettier-config": "^1.0.1", | ||
"peerDependencies": { | ||
"@capacitor/core": "^3.0.0" | ||
"@capacitor/core": "^4.0.0" | ||
}, | ||
@@ -75,0 +76,0 @@ "prettier": "@ionic/prettier-config", |
# Capacitor E-Mail Composer | ||
![Maintenance](https://img.shields.io/maintenance/yes/2021) | ||
![Maintenance](https://img.shields.io/maintenance/yes/2022) | ||
[![npm](https://img.shields.io/npm/v/capacitor-email-composer)](https://www.npmjs.com/package/capacitor-email-composer) | ||
👉🏼 **Note**: this Plugin is developed for Capacitor V3 | ||
This Plugin is used to open a native E-Mail Composer within your Capacitor App. | ||
@@ -23,2 +21,7 @@ | ||
- [Install](#install) | ||
- [Attachments](#attachments) | ||
- [Device Storage](#device-storage) | ||
- [Native resources](#native-resources) | ||
- [Assets](#assets) | ||
- [Base64](#base64) | ||
- [API](#api) | ||
@@ -39,2 +42,60 @@ - [hasAccount()](#hasaccount) | ||
## Attachments | ||
You can add attachments to the draft mail by using the `attachments` option in the `open(...)` method. | ||
Every attachment needs a `type` and a `path`. If you are adding a `base64` type attachment, you also need to set the `name`: | ||
### Device Storage | ||
The path to the files must be defined absolute from the root of the file system. On Android the user has to allow the app first to read from external storage! | ||
```ts | ||
EmailComposerPlugin.open({ | ||
attachments: [{ | ||
type: 'absolute', | ||
path: 'storage/sdcard/icon.png' // Android | ||
}] | ||
}) | ||
``` | ||
### Native resources | ||
Each app has a resource folder, e.g. the res folder for Android apps or the Resource folder for iOS apps. The following example shows how to attach the app icon from within the app's resource folder. | ||
```ts | ||
EmailComposerPlugin.open({ | ||
attachments: [{ | ||
type: 'resource', | ||
path: 'icon.png' | ||
}] | ||
}) | ||
``` | ||
### Assets | ||
The path to the files must be defined relative from the root of the mobile web app assets folder, which is located under the build folder. | ||
```ts | ||
EmailComposerPlugin.open({ | ||
attachments: [{ | ||
type: 'asset', | ||
path: '/icon/favicon.png' // starting slash is important | ||
}] | ||
}) | ||
``` | ||
### Base64 | ||
The code below shows how to attach a base64 encoded image which will be added as an image. **You must set a name**. | ||
```ts | ||
EmailComposerPlugin.open({ | ||
attachments: [{ | ||
type: 'base64', | ||
path: 'iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6...', | ||
name: 'icon.png' // this is required | ||
}] | ||
}) | ||
``` | ||
## API | ||
@@ -88,11 +149,21 @@ | ||
| Prop | Type | Description | | ||
| ------------- | --------------------- | ---------------------------------------------------------- | | ||
| **`to`** | <code>string[]</code> | email addresses for TO field | | ||
| **`cc`** | <code>string[]</code> | email addresses for CC field | | ||
| **`bcc`** | <code>string[]</code> | email addresses for BCC field | | ||
| **`subject`** | <code>string</code> | subject of the email | | ||
| **`body`** | <code>string</code> | email body | | ||
| **`isHtml`** | <code>boolean</code> | indicats if the body is HTML or plain text (primarily iOS) | | ||
| Prop | Type | Description | | ||
| ----------------- | ------------------------- | ------------------------------------------------------------------------ | | ||
| **`to`** | <code>string[]</code> | email addresses for TO field | | ||
| **`cc`** | <code>string[]</code> | email addresses for CC field | | ||
| **`bcc`** | <code>string[]</code> | email addresses for BCC field | | ||
| **`subject`** | <code>string</code> | subject of the email | | ||
| **`body`** | <code>string</code> | email body | | ||
| **`isHtml`** | <code>boolean</code> | indicates if the body is HTML or plain text (primarily iOS) | | ||
| **`attachments`** | <code>Attachment[]</code> | attachments that are added to the mail file paths or base64 data streams | | ||
#### Attachment | ||
| Prop | Type | Description | | ||
| ---------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | | ||
| **`path`** | <code>string</code> | The path of the attachment. See the docs for explained informations. | | ||
| **`type`** | <code>'absolute' \| 'resource' \| 'asset' \| 'base64'</code> | The type of the attachment. See the docs for explained informations. | | ||
| **`name`** | <code>string</code> | The name of the attachment. See the docs for explained informations. Required for base64 attachements. | | ||
</docgen-api> | ||
@@ -99,0 +170,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
40912
27
379
171
22