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';
declare var cordova;
/**
* Email object for Opening Email Composer
*/
@ -25,6 +27,12 @@ export interface email {
* import {EmailComposer} from 'ionic-native';
*
*
* EmailComposer.isAvailable().then((available) =>{
* if(available) {
* //Now we know we can send
* }
* });
*
* let email = {
* to: 'max@mustermann.de',
* cc: 'erika@mustermann.de',
@ -53,24 +61,39 @@ export interface email {
})
export class EmailComposer {
@Cordova({
successIndex: 1,
errorIndex: 3
})
static isAvailable(app: string, scope: any) : Promise<boolean> {return}
@Cordova()
static addAlias(alias: string, packageName: string): void {}
/**
* 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
*/
static isAvailable (app? : string, scope? : any) : Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
cordova.plugins.email.isAvailable(app, resolve, scope);
});
}
/**
* Opens Email Composer with email contents
* Adds a new mail app alias.
*
* @param alias {string} The alias name
* @param packageName {string} The package name
*/
@Cordova()
static addAlias(alias : string, packageName : string): void {}
/**
* Displays the email composer pre-filled with data.
*
* @param email {email} Email
* @param scope {any?} An optional scope for the promise
* @returns {Promise<any>} Resolves promise when the EmailComposer has been opened
*/
@Cordova({
successIndex: 1,
errorIndex: 3
})
static open(email: email, scope: any) : Promise<any> {return}
static open(email : email, scope? : any) : Promise<any> {return}
}