UNPKG

@ionic-native/email-composer

Version:

Ionic Native - Native plugins for ionic apps

98 lines (93 loc) 4.09 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var tslib = require('tslib'); var core$1 = require('@angular/core'); var core = require('@ionic-native/core'); var EmailComposer = /** @class */ (function (_super) { tslib.__extends(EmailComposer, _super); function EmailComposer() { return _super !== null && _super.apply(this, arguments) || this; } EmailComposer.prototype.hasPermission = function () { return core.cordova(this, "hasPermission", { "successIndex": 0, "errorIndex": 2 }, arguments); }; EmailComposer.prototype.requestPermission = function () { return core.cordova(this, "requestPermission", { "successIndex": 0, "errorIndex": 2 }, arguments); }; EmailComposer.prototype.hasAccount = function () { var _this = this; return (function () { if (core.checkAvailability(_this) === true) { return core.getPromise(function (resolve) { EmailComposer.getPlugin().hasAccount(function (result) { if (result) { resolve(true); } else { resolve(false); } }); }); } })(); }; EmailComposer.prototype.hasClient = function (app) { var _this = this; return (function () { if (core.checkAvailability(_this) === true) { return core.getPromise(function (resolve) { if (app) { EmailComposer.getPlugin().hasClient(app, function (result) { if (result) { resolve(true); } else { resolve(false); } }); } else { EmailComposer.getPlugin().getClients(function (apps) { resolve(apps && apps.length > 0); }); } }); } })(); }; EmailComposer.prototype.getClients = function () { var _this = this; return (function () { if (core.checkAvailability(_this) === true) { return core.getPromise(function (resolve) { EmailComposer.getPlugin().getClients(function (apps) { if (Object.prototype.toString.call(apps) === '[object String]') { apps = [apps]; } resolve(apps); }); }); } })(); }; EmailComposer.prototype.isAvailable = function (app) { var _this = this; return (function () { if (core.checkAvailability(_this) === true) { return core.getPromise(function (resolve) { Promise.all([_this.hasAccount, _this.hasClient(app)]).then(function (results) { return resolve(results.length === 2 && results[0] && results[1]); }); }); } })(); }; EmailComposer.prototype.open = function (options, scope) { return core.cordova(this, "open", { "successIndex": 1, "errorIndex": 3 }, arguments); }; EmailComposer.prototype.addAlias = function (alias, packageName) { return core.cordova(this, "addAlias", {}, arguments); }; EmailComposer.pluginName = "EmailComposer"; EmailComposer.plugin = "cordova-plugin-email-composer"; EmailComposer.pluginRef = "cordova.plugins.email"; EmailComposer.repo = "https://github.com/katzer/cordova-plugin-email-composer"; EmailComposer.platforms = ["Amazon Fire OS", "Android", "Browser", "iOS", "Windows", "macOS"]; EmailComposer.decorators = [ { type: core$1.Injectable } ]; return EmailComposer; }(core.IonicNativePlugin)); exports.EmailComposer = EmailComposer;