Refactor isAvailable

This commit is contained in:
Christopher Manouvrier 2016-04-06 22:06:46 +10:00
parent f96ec32be7
commit ce92e6ac8f

View File

@ -1,5 +1,7 @@
import {Plugin, Cordova} from './plugin'; import {Plugin, Cordova} from './plugin';
declare var cordova;
/** /**
* Email object for Opening Email Composer * Email object for Opening Email Composer
*/ */
@ -24,6 +26,12 @@ export interface email {
* ```ts * ```ts
* import {EmailComposer} from 'ionic-native'; * import {EmailComposer} from 'ionic-native';
* *
*
* EmailComposer.isAvailable().then((available) =>{
* if(available) {
* //Now we know we can send
* }
* });
* *
* let email = { * let email = {
* to: 'max@mustermann.de', * to: 'max@mustermann.de',
@ -53,24 +61,39 @@ export interface email {
}) })
export class EmailComposer { export class EmailComposer {
@Cordova({ /**
successIndex: 1, * Verifies if sending emails is supported on the device.
errorIndex: 3 *
}) * @param app {string?} An optional app id or uri scheme. Defaults to mailto.
static isAvailable(app: string, scope: any) : Promise<boolean> {return} * @param scope {any?} An optional scope for the promise
* @returns {Promise<boolean>} Resolves promise with boolean whether EmailComposer is available
*/
static isAvailable (app? : string, scope? : any) : Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
cordova.plugins.email.isAvailable(app, resolve, scope);
});
}
/**
* Adds a new mail app alias.
*
* @param alias {string} The alias name
* @param packageName {string} The package name
*/
@Cordova() @Cordova()
static addAlias(alias: string, packageName: string): void {} static addAlias(alias : string, packageName : string): void {}
/** /**
* Opens Email Composer with email contents * Displays the email composer pre-filled with data.
*
* @param email {email} Email * @param email {email} Email
* @param scope {any?} An optional scope for the promise
* @returns {Promise<any>} Resolves promise when the EmailComposer has been opened * @returns {Promise<any>} Resolves promise when the EmailComposer has been opened
*/ */
@Cordova({ @Cordova({
successIndex: 1, successIndex: 1,
errorIndex: 3 errorIndex: 3
}) })
static open(email: email, scope: any) : Promise<any> {return} static open(email : email, scope? : any) : Promise<any> {return}
} }