@nativescript/appversion
读取您的 NativeScript 应用版本
npm i --save @nativescript/appversion

NativeScript AppVersion

NPM version Downloads Twitter Follow

读取您 NativeScript 应用的当前包 ID 和版本(名称和代码)。

安装

从项目的根目录运行以下命令

tns plugin add @nativescript/appversion

用法

要使用此插件,您必须首先 require / import 它

JavaScript

var appversion = require("@nativescript/appversion");

TypeScript

import * as appversion from "@nativescript/appversion";

getVersionName(Sync)

getVersionNameSyncgetVersionName 相同,只不过它不返回一个 Promise。

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(Sync)

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(Sync)

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);
});