nativeScript-app-version
读取您的 NativeScript 应用版本
npm i --save nativescript-app-version

NativeScript AppVersion

需要 NativeScript 2.3.0(由于 iOS 10 兼容性),所以如果您使用的是较低版本,请升级:npm install -g nativescript

读取您的 NativeScript 应用版本。

对于 iOS,我们从 *.plistCFBundleShortVersionString 中读取。

对于 Android,我们从 AndroidManifest.xml 中读取 versionName

安装

在项目根目录下运行以下命令

tns plugin add nativescript-appversion

用法

要使用此插件,您必须首先 require() 它

var appversion = require("nativescript-appversion");

getVersionName

JavaScript

  appversion.getVersionName().then(function(v) {
console.log("Your app's version is: " + v);
});

TypeScript

  appversion.getVersionName().then((v: string) {
console.log("Your app's version is: " + v);
});

getVersionCode

JavaScript

  appversion.getVersionCode().then(function(v) {
console.log("Your app's version code is: " + v);
});

TypeScript

  appversion.getVersionCode().then((v: string) {
console.log("Your app's version code is: " + v);
});

getAppId

JavaScript

  appversion.getAppId().then(function(id) {
console.log("Your app's id is: " + id);
});

TypeScript

  appversion.getAppId().then((id: string) {
console.log("Your app's id is: " + id);
});