4.0.0 • Published 5 years ago

cordova-plugin-buildinfo v4.0.0

Weekly downloads
2,388
License
MIT
Repository
github
Last release
5 years ago

Build Status Code Climate MIT License downloads

cordova-plugin-buildinfo

This plugin defines a global BuildInfo object.

BuildInfo object is available at the time the deviceready event fires.

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
	console.log('BuildInfo.baseUrl        =' + BuildInfo.baseUrl);
	console.log('BuildInfo.packageName    =' + BuildInfo.packageName);
	console.log('BuildInfo.basePackageName=' + BuildInfo.basePackageName);
	console.log('BuildInfo.displayName    =' + BuildInfo.displayName);
	console.log('BuildInfo.name           =' + BuildInfo.name);
	console.log('BuildInfo.version        =' + BuildInfo.version);
	console.log('BuildInfo.versionCode    =' + BuildInfo.versionCode);
	console.log('BuildInfo.debug          =' + BuildInfo.debug);
	console.log('BuildInfo.buildType      =' + BuildInfo.buildType);
	console.log('BuildInfo.flavor         =' + BuildInfo.flavor);
	console.log('BuildInfo.buildDate      =' + BuildInfo.buildDate);
	console.log('BuildInfo.installDate    =' + BuildInfo.installDate);
}

Installation

cordova plugin add cordova-plugin-buildinfo

Supported Platforms

  • Android
  • iOS
  • Windows
  • macOS(OS X)
  • Browser
  • Electron

Properties

BuildInfo.baseUrl

Get the cordova.js file exists path.
Path last character is '/'.

PlatformValueType
AndroidPathString
iOSPathString
WindowsPathString
macOS(OS X)PathString
BrowserPathString
ElectronPathString

BuildInfo.packageName

Get the packageName of Application ID.

PlatformValueType
AndroidPackage NameString
iOSBundle IdentifierString
WindowsIdentity nameString
macOS(OS X)Bundle IdentifierString
BrowserGet the id attribute of the widget element in config.xml file.String
ElectronGet the id attribute of the widget element in config.xml file.String

BuildInfo.basePackageName

Android only.

Get the packageName of BuildConfig class.

If you use the configure of "build types" or "product flavors", because you can specify a different package name is the id attribute of the widget element of config.xml, is the property to get the package name that BuildConfig class belongs. (ought be the same as the id attribute of the widget element of config.xml)

PlatformValueType
AndroidPackage name of BuildConfig classString
iOSBundle Identifier(equals BuildInfo.packageName)String
WindowsIdentity name(equals BuildInfo.packageName)String
macOS(OS X)Bundle Identifier(equals BuildInfo.packageName)String
Browserequals BuildInfo.packageNameString
Electronequals BuildInfo.packageNameString

BuildInfo.displayName

Get the displayName.

PlatformValueType
AndroidApplication LabelString
iOSCFBundleDisplayName (CFBundleName if not present)String
WindowsGet the DisplayName attribute of the VisualElements element in AppxManifest.xml file.String
macOS(OS X)CFBundleDisplayName (CFBundleName if not present)String
BrowserGet the short attribute of the name element in config.xml file.String
ElectronGet the short attribute of the name element in config.xml file.String

BuildInfo.name

Get the name.

PlatformValueType
AndroidApplication Label(equal BuildInfo.displayName)String
iOSCFBundleNameString
WindowsWindows Store display nameString
macOS(OS X)CFBundleNameString
BrowserGet value of the name element in config.xml file.String
ElectronGet value of the name element in config.xml file.String

BuildInfo.version

Get the version.

PlatformValueType
AndroidBuildConfig.VERSION_NAMEString
iOSCFBundleShortVersionStringString
WindowsMajor.Minor.Build ex) "1.2.3"String
macOS(OS X)CFBundleShortVersionStringString
BrowserGet the version attribute of the widget element in config.xml file.String
ElectronGet the version attribute of the widget element in config.xml file.String

BuildInfo.versionCode

Get the version code.

PlatformValueType
AndroidBuildConfig.VERSION_CODEinteger
iOSCFBundleVersionString
WindowsMajor.Minor.Build.Revision ex) "1.2.3.4"String
macOS(OS X)CFBundleVersionString
Browserequals BuildInfo.versionString
Electronequals BuildInfo.versionString

BuildInfo.debug

Get the debug flag.

PlatformValueType
AndroidBuildConfig.DEBUGBoolean
iOSdefined "DEBUG" is trueBoolean
WindowsisDevelopmentMode is trueBoolean
macOS(OS X)defined "DEBUG" is trueBoolean
BrowserAlways falseBoolean
ElectronTrue when cordova build electron --debug is executed with the "--debug" flag.Boolean

BuildInfo.buildType

Android , Windows Only.

Get the build type.

PlatformValueType
AndroidBuildConfig.BUILD_TYPEString
iOSempty stringString
Windows"release" or "debug"String
macOS(OS X)empty stringString
Browserempty stringString
Electronempty stringString

BuildInfo.flavor

Android Only.

Get the flavor.

PlatformValueType
AndroidBuildConfig.FLAVORString
iOSempty stringString
Windowsempty stringString
macOS(OS X)empty stringString
Browserempty stringString
Electronempty stringString

BuildInfo.buildDate

Get the build date and time in the Date object returns.

Attention:

  • Android: Add the BuildInfo.gradle file to your Android project.
    The BuildInfo.gradle file contains the setting to add the _BUILDINFO_TIMESTAMP field to the BuildConfig class.
  • Windows: Add the buildinfo.resjson file to your Windows project.
    The buildinfo.resjson file into the "strings" folder.
    And also add a task to rewrite buildinfo.resjson in the CordovaApp.projitems file.
  • Browser and Electron: When cordova prepare is executed Build date and time is embedded in
    platforms/browser/www/plugins/cordova-plugin-buildinfo/src/browser/BuildInfoProxy.js file.
    (Or platforms/electron/www/plugins/cordova-plugin-buildinfo/src/browser/BuildInfoProxy.js file.)
    cordova prepare is also executed for cordova build, cordova run and cordova platform add.
    (Reference: Hooks Guide - Apache Cordova)
PlatformValueType
AndroidBuildConfig._BUILDINFO_TIMESTAMP valueDate
iOSGet the modification date and time of the Info.plist file acquired from the executionPath property of the main bundle.Date
WindowsResource value of "/buildinfo/Timestamp" string.Date
macOS(OS X)Get the modification date and time of the config.xml file acquired from the resource of the main bundle.Date
BrowserThe date and time when cordova prepare was executed.Date
ElectronThe date and time when cordova prepare was executed.Date

BuildInfo.installDate

Get the install date and time in the Date object returns.

Attention:

  • Browser and Electron: Installation date and time is unknown.
PlatformValueType
AndroidThe firstInstallTime property of PackageInfoDate
iOSGet the creation date and time of the document directory.Date
WindowsThe installedDate property of Windows.ApplicatinoModel.Package.currentDate
macOS(OS X)Date and time of kMDItemDateAdded recorded in File Metadata of application package.Date
BrowserNot available.null
ElectronNot available.null

BuildInfo.windows

Windows Only.

Get the windows extra information.

PlatformValueType
Androidundefinedundefined
iOSundefinedundefined
WindowsObjectObject
macOS(OS X)undefinedundefined
Browserundefinedundefined
Electronundefinedundefined
Property nameValueType
architectureWindows.ApplicationModel.Package.current.id.architectureinteger
descriptionWindows.ApplicationModel.Package.current.descriptionString
displayNameWindows.ApplicationModel.Package.current.displayNameString
familyNameWindows.ApplicationModel.Package.current.id.familyNameString
fullNameWindows.ApplicationModel.Package.current.id.fullNameString
logoObjectObject
publisherWindows.ApplicationModel.Package.current.id.publisherString
publisherIdWindows.ApplicationModel.Package.current.id.publisherIdString
publisherDisplayNameWindows.ApplicationModel.Package.current.publisherDisplayNameString
resourceIdWindows.ApplicationModel.Package.current.id.resourceIdString
versionWindows.ApplicationModel.Package.current.id.versionObject

BuildInfo.windows.logo

Property nameValueType
absoluteCannonicalUriWindows.ApplicationModel.Package.logo.absoluteCanonicalUriString
absoluteUriWindows.ApplicationModel.Package.logo.absoluteUriString
displayIriWindows.ApplicationModel.Package.logo.displayIriString
displayUriWindows.ApplicationModel.Package.logo.displayUriString
pathWindows.ApplicationModel.Package.logo.pathString
rawUriWindows.ApplicationModel.Package.logo.rawUriString

BuildInfo.windows.version

Property nameValueType
majorWindows.ApplicationModel.Package.current.id.version.majorinteger
minorWindows.ApplicationModel.Package.current.id.version.minorinteger
buildWindows.ApplicationModel.Package.current.id.version.buildinteger
revisionWindows.ApplicationModel.Package.current.id.version.revisioninteger