UNPKG

ionic-native

Version:

Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support

119 lines 4.19 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { Cordova, Plugin } from './plugin'; /** * @beta * @name Email Composer * @description * * Requires Cordova plugin: cordova-plugin-email-composer. For more info, please see the [Email Composer plugin docs](https://github.com/hypery2k/cordova-email-plugin). * * DISCLAIMER: This plugin is experiencing issues with the latest versions of Cordova. Use at your own risk. Functionality is not guaranteed. Please stay tuned for a more stable version. * A good alternative to this plugin is the social sharing plugin. * * @usage * ```typescript * import { EmailComposer } from 'ionic-native'; * * * EmailComposer.isAvailable().then((available: boolean) =>{ * if(available) { * //Now we know we can send * } * }); * * 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.open(email); * * ``` * @interfaces * EmailComposerOptions */ export var EmailComposer = (function () { function EmailComposer() { } /** * Verifies if sending emails is supported on the device. * * @param app {string?} An optional app id or uri scheme. * @returns {Promise<any>} Resolves if available, rejects if not available */ EmailComposer.isAvailable = function (app) { return new Promise(function (resolve, reject) { if (app) { cordova.plugins.email.isAvailable(app, function (isAvailable) { if (isAvailable) { resolve(); } else { reject(); } }); } else { cordova.plugins.email.isAvailable(function (isAvailable) { if (isAvailable) { resolve(); } else { reject(); } }); } }); }; /** * Adds a new mail app alias. * * @param alias {string} The alias name * @param packageName {string} The package name */ EmailComposer.addAlias = function (alias, packageName) { }; /** * Displays the email composer pre-filled with data. * * @param options {EmailComposerOptions} Email * @param scope {any?} An optional scope for the promise * @returns {Promise<any>} Resolves promise when the EmailComposer has been opened */ EmailComposer.open = function (options, scope) { return; }; __decorate([ Cordova() ], EmailComposer, "addAlias", null); __decorate([ Cordova({ successIndex: 1, errorIndex: 3 }) ], EmailComposer, "open", null); EmailComposer = __decorate([ Plugin({ pluginName: 'EmailComposer', plugin: 'cordova-plugin-email', pluginRef: 'cordova.plugins.email', repo: 'https://github.com/hypery2k/cordova-email-plugin', platforms: ['Android', 'iOS'] }) ], EmailComposer); return EmailComposer; }()); //# sourceMappingURL=emailcomposer.js.map