fix(emailcomposer): fix isAvailable function

function now returns a promise that resolves if email composer is available, and rejects if it's not

partially fixes #168
This commit is contained in:
Ibrahim Hadeed 2016-05-20 14:06:13 -04:00
parent 3c49face4c
commit 2a568d2398

View File

@ -64,13 +64,13 @@ export class EmailComposer {
/**
* Verifies if sending emails is supported on the device.
*
* @param app {string?} An optional app id or uri scheme. Defaults to mailto.
* @param scope {any?} An optional scope for the promise
* @returns {Promise<boolean>} Resolves promise with boolean whether EmailComposer is available
* @param app {string?} An optional app id or uri scheme.
* @returns {Promise<boolean>} Resolves if available, rejects if not available
*/
static isAvailable (app?: string, scope?: any): Promise<boolean> {
static isAvailable (app?: string): Promise<any> {
return new Promise<boolean>((resolve, reject) => {
cordova.plugins.email.isAvailable(app, resolve, scope);
if (app) cordova.plugins.email.isAvailable(app, (isAvailable) => { if (isAvailable) resolve(); else reject(); });
else cordova.plugins.email.isAvailable((isAvailable) => { if (isAvailable) resolve(); else reject(); });
});
}