awesome-cordova-plugins/src/plugins/appversion.ts

82 lines
2.6 KiB
TypeScript
Raw Normal View History

2016-02-17 17:25:03 +08:00
import {Plugin, Cordova} from './plugin';
/**
* Reads the version of your app from the target build settings.
*
2016-03-05 05:42:21 +08:00
* Requires Cordova plugin: `cordova-plugin-app-version`. For more info, please see the [Cordova App Version docs](ttps://github.com/whiteoctober/cordova-plugin-app-version).
2016-02-17 17:25:03 +08:00
*
* ```
2016-03-05 05:42:21 +08:00
* cordova plugin add cordova-plugin-app-version
2016-02-17 17:25:03 +08:00
* ````
*
* @usage
* ```js
* AppVersion.getAppName();
* AppVersion.getPackageName();
* AppVersion.getVersionCode();
* AppVersion.getVersionNumber();
* ```
*/
@Plugin({
2016-03-05 05:42:21 +08:00
plugin: 'cordova-plugin-app-version',
2016-02-17 17:25:03 +08:00
pluginRef: 'cordova.getAppVersion'
})
export class AppVersion {
/**
* Returns the name of the app
2016-03-05 05:42:21 +08:00
* @returns {Promise}
2016-02-17 17:25:03 +08:00
*/
2016-03-05 05:42:21 +08:00
@Cordova()
static getAppName () {
// This Promise is replaced by one from the @Cordova decorator that wraps
// the plugin's callbacks. We provide a dummy one here so TypeScript
// knows that the correct return type is Promise, because there's no way
// for it to know the return type from a decorator.
// See https://github.com/Microsoft/TypeScript/issues/4881
return new Promise<any>((res, rej) => {});
2016-02-17 17:25:03 +08:00
}
/**
* Returns the package name of the app
2016-03-05 05:42:21 +08:00
* @returns {Promise}
2016-02-17 17:25:03 +08:00
*/
2016-03-05 05:42:21 +08:00
@Cordova()
static getPackageName () {
// This Promise is replaced by one from the @Cordova decorator that wraps
// the plugin's callbacks. We provide a dummy one here so TypeScript
// knows that the correct return type is Promise, because there's no way
// for it to know the return type from a decorator.
// See https://github.com/Microsoft/TypeScript/issues/4881
return new Promise<any>((res, rej) => {});
2016-02-17 17:25:03 +08:00
}
/**
* Returns the build identifier of the app
2016-03-05 05:42:21 +08:00
* @returns {Promise}
2016-02-17 17:25:03 +08:00
*/
2016-03-05 05:42:21 +08:00
@Cordova()
static getVersionCode () {
// This Promise is replaced by one from the @Cordova decorator that wraps
// the plugin's callbacks. We provide a dummy one here so TypeScript
// knows that the correct return type is Promise, because there's no way
// for it to know the return type from a decorator.
// See https://github.com/Microsoft/TypeScript/issues/4881
return new Promise<any>((res, rej) => {});
2016-02-17 17:25:03 +08:00
}
/**
* Returns the version of the app
2016-03-05 05:42:21 +08:00
* @returns {Promise}
2016-02-17 17:25:03 +08:00
*/
2016-03-05 05:42:21 +08:00
@Cordova()
static getVersionNumber() {
// This Promise is replaced by one from the @Cordova decorator that wraps
// the plugin's callbacks. We provide a dummy one here so TypeScript
// knows that the correct return type is Promise, because there's no way
// for it to know the return type from a decorator.
// See https://github.com/Microsoft/TypeScript/issues/4881
return new Promise<any>((res, rej) => {});
2016-02-17 17:25:03 +08:00
}
}