From 804c9ee4634976e059c7b2e3cdd5b4817766a29c Mon Sep 17 00:00:00 2001 From: Christopher Manouvrier Date: Tue, 5 Apr 2016 21:55:24 +1000 Subject: [PATCH] feat(plugin): add email composer plugin --- src/index.ts | 3 ++ src/plugins/emailcomposer.ts | 63 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/plugins/emailcomposer.ts diff --git a/src/index.ts b/src/index.ts index 6044e5dea9..bfc2b22e8a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,6 +25,7 @@ import {DeviceMotion} from './plugins/devicemotion'; import {DeviceOrientation} from './plugins/deviceorientation'; import {Diagnostic} from './plugins/diagnostic'; import {Dialogs} from './plugins/dialogs'; +import {EmailComposer} from './plugins/emailcomposer'; import {Facebook} from './plugins/facebook'; import {File} from './plugins/file'; import {Flashlight} from './plugins/flashlight'; @@ -69,6 +70,7 @@ export { DeviceOrientation, Dialogs, Diagnostic, + EmailComposer, Facebook, File, Flashlight, @@ -117,6 +119,7 @@ window['IonicNative'] = { DeviceOrientation: DeviceOrientation, Dialogs: Dialogs, Diagnostic: Diagnostic, + EmailComposer: EmailComposer, Facebook: Facebook, File: File, Flashlight: Flashlight, diff --git a/src/plugins/emailcomposer.ts b/src/plugins/emailcomposer.ts new file mode 100644 index 0000000000..6d5d9b4a9c --- /dev/null +++ b/src/plugins/emailcomposer.ts @@ -0,0 +1,63 @@ +import {Plugin, Cordova} from './plugin'; + +/** + * Email object for Opening Email Composer + */ +export interface email { + to: string | Array, + cc: string | Array, + bcc: string | Array, + attachments: Array, + subject: string, + body: string, + isHtml: boolean +} + +/** + * @name Email Composer + * @description + * + * Requires Cordova plugin: cordova-plugin-email-composer. For more info, please see the [Email Composer plugin docs](https://github.com/katzer/cordova-plugin-email-composer). + * + * @usage + * ```ts + * import {EmailComposer} from 'ionic-native'; + * + * + * let email = { + * to: 'max@mustermann.de', + * cc: 'erika@mustermann.de', + * bcc: ['john@doe.com', 'jane@doe.com'], + * attachments: [ + * 'file://img/logo.png', + * 'res://icon.png', + * 'base64:icon.png//iVBORw0KGgoAAAANSUhEUg...', + * 'file://README.pdf' + * ], + * subject: 'Cordova Icons', + * body: 'How are you? Nice greetings from Leipzig', + * isHtml: true + * }; + * + * // Send a text message using default options + * EmailComposer.send(email); + * + * ``` + */ +@Plugin({ + plugin: 'cordova-plugin-email-composer', + pluginRef: 'emailComposer', + repo: 'https://github.com/katzer/cordova-plugin-email-composer.git', + platforms: ['Android', 'iOS', 'Windows Phone 8'] +}) +export class EmailComposer { + + /** + * Opens Email Composer with email contents + * @param email {email} Email + * @returns {Promise} Resolves promise when the EmailComposer has been opened + */ + @Cordova() + static open(email: email): Promise { return } + +}