|
| 1 | +# cordova-plugin-buildinfo |
| 2 | + |
| 3 | +このプラグインは、BuildInfoをグローバルのオブジェクトとして定義します。 |
| 4 | + |
| 5 | +BuildInfoは deviceready イベントが発火した時点で有効になっています。 |
| 6 | + |
| 7 | +```js |
| 8 | +document.addEventListener("deviceready", onDeviceReady, false); |
| 9 | + |
| 10 | +function onDeviceReady() { |
| 11 | + console.log('BuildInfo.baseUrl =' + BuildInfo.baseUrl); |
| 12 | + console.log('BuildInfo.packageName =' + BuildInfo.packageName); |
| 13 | + console.log('BuildInfo.basePackageName=' + BuildInfo.basePackageName); |
| 14 | + console.log('BuildInfo.displayName =' + BuildInfo.displayName); |
| 15 | + console.log('BuildInfo.name =' + BuildInfo.name); |
| 16 | + console.log('BuildInfo.version =' + BuildInfo.version); |
| 17 | + console.log('BuildInfo.versionCode =' + BuildInfo.versionCode); |
| 18 | + console.log('BuildInfo.debug =' + BuildInfo.debug); |
| 19 | + console.log('BuildInfo.buildType =' + BuildInfo.buildType); |
| 20 | + console.log('BuildInfo.flavor =' + BuildInfo.flavor); |
| 21 | + console.log('BuildInfo.buildDate =' + BuildInfo.buildDate); |
| 22 | + console.log('BuildInfo.installDate =' + BuildInfo.installDate); |
| 23 | +} |
| 24 | +``` |
| 25 | + |
| 26 | +## インストール |
| 27 | + |
| 28 | +```sh |
| 29 | +cordova plugin add cordova-plugin-buildinfo |
| 30 | +``` |
| 31 | + |
| 32 | +## サポートプラットフォーム |
| 33 | + |
| 34 | +* Android |
| 35 | +* iOS |
| 36 | +* Windows |
| 37 | +* macOS(OS X) |
| 38 | +* Browser |
| 39 | +* Electron |
| 40 | + |
| 41 | +## プロパティ |
| 42 | + |
| 43 | +- [`BuildInfo.baseUrl`](#BuildInfo.baseUrl) |
| 44 | +- [`BuildInfo.packageName`](#BuildInfo.packageName) |
| 45 | +- [`BuildInfo.basePackageName`](#BuildInfo.basePackageName) |
| 46 | +- [`BuildInfo.displayName`](#BuildInfo.displayName) |
| 47 | +- [`BuildInfo.name`](#BuildInfo.name) |
| 48 | +- [`BuildInfo.version`](#BuildInfo.version) |
| 49 | +- [`BuildInfo.versionCode`](#BuildInfo.versionCode) |
| 50 | +- [`BuildInfo.debug`](#BuildInfo.debug) |
| 51 | +- [`BuildInfo.buildType`](#BuildInfo.buildType) |
| 52 | +- [`BuildInfo.flavor`](#BuildInfo.flavor) |
| 53 | +- [`BuildInfo.buildDate`](#BuildInfo.buildDate) |
| 54 | +- [`BuildInfo.installDate`](#BuildInfo.installDate) |
| 55 | +- [`BuildInfo.windows`](#BuildInfo.windows) |
| 56 | + - [`logo`](#BuildInfo.windows.logo) |
| 57 | + - [`version`](#BuildInfo.windows.version) |
| 58 | + |
| 59 | +### BuildInfo.baseUrl |
| 60 | + |
| 61 | +cordova.js ファイルがあるパスを取得します。 |
| 62 | +パスの最後は "/" が付きます。 |
| 63 | + |
| 64 | +|Platform|Value|Type| |
| 65 | +|--------|-----|----| |
| 66 | +|Android|Path|String| |
| 67 | +|iOS|Path|String| |
| 68 | +|Windows|Path|String| |
| 69 | +|macOS(OS X)|Path|String| |
| 70 | +|Browser|Path|String| |
| 71 | +|Electron|Path|String| |
| 72 | + |
| 73 | +### BuildInfo.packageName |
| 74 | + |
| 75 | +Application IDをpackageNameとして取得します。 |
| 76 | + |
| 77 | +|Platform|Value|Type| |
| 78 | +|--------|-----|----| |
| 79 | +|Android|Package Name|String| |
| 80 | +|iOS|Bundle Identifier|String| |
| 81 | +|Windows|Identity name|String| |
| 82 | +|macOS(OS X)|Bundle Identifier|String| |
| 83 | +|Browser|config.xml の widget 要素に設定されている id 属性の値が入ります|String| |
| 84 | +|Electron|config.xml の widget 要素に設定されている id 属性の値が入ります|String| |
| 85 | + |
| 86 | + |
| 87 | +### BuildInfo.basePackageName |
| 88 | + |
| 89 | +Androidのみ。 |
| 90 | + |
| 91 | +BuildConfigクラスのpackageNameを取得します。 |
| 92 | + |
| 93 | +ビルドタイプやFlavorを利用すると、config.xmlのwidget要素で指定したidとは異なるパッケージ名を指定できるため、BuildConfigクラスが属するパッケージ名を取得するためのプロパティです。 |
| 94 | +(config.xmlのwidget要素にあるid属性と同じになるはずです) |
| 95 | + |
| 96 | + |
| 97 | +|Platform|Value|Type| |
| 98 | +|--------|-----|----| |
| 99 | +|Android|BuildConfigクラスにあるパッケージ名|String| |
| 100 | +|iOS|Bundle Identifier(BuildInfo.packageNameと同一)|String| |
| 101 | +|Windows|Identity name(BuildInfo.packageNameと同一)|String| |
| 102 | +|macOS(OS X)|Bundle Identifier(BuildInfo.packageNameと同一)|String| |
| 103 | +|Browser|BuildInfo.packageName と同一|String| |
| 104 | +|Electron|BuildInfo.packageName と同一|String| |
| 105 | + |
| 106 | + |
| 107 | +### BuildInfo.displayName |
| 108 | + |
| 109 | +アプリのホーム画面での表示名を取得します。 |
| 110 | + |
| 111 | +|Platform|Value|Type| |
| 112 | +|--------|-----|----| |
| 113 | +|Android|Application Label|String| |
| 114 | +|iOS|CFBundleDisplayName(存在しない場合はCFBundleName)|String| |
| 115 | +|Windows|AppxManifest.xmlのVisualElements要素にあるDisplayName属性|String| |
| 116 | +|macOS(OS X)|CFBundleDisplayName(存在しない場合はCFBundleName)|String| |
| 117 | +|Browser|config.xml の name 要素の short 属性の値が入ります|String| |
| 118 | +|Electron|config.xml の name 要素の short 属性の値が入ります|String| |
| 119 | + |
| 120 | +### BuildInfo.name |
| 121 | + |
| 122 | +アプリの名前を取得します。 |
| 123 | +(iOSのみ。Androidでは、displayNameと同一になります) |
| 124 | + |
| 125 | +|Platform|Value|Type| |
| 126 | +|--------|-----|----| |
| 127 | +|Android|Application Label(BuildInfo.displayNameと同一)|String| |
| 128 | +|iOS|CFBundleName|String| |
| 129 | +|Windows|Windows Store display name|String| |
| 130 | +|macOS(OS X)|CFBundleName|String| |
| 131 | +|Browser|config.xml の name 要素の内容が入ります|String| |
| 132 | +|Electron|config.xml の name 要素の内容が入ります|String| |
| 133 | + |
| 134 | + |
| 135 | +### BuildInfo.version |
| 136 | + |
| 137 | +バージョンを取得します。 |
| 138 | + |
| 139 | +|Platform|Value|Type| |
| 140 | +|--------|-----|----| |
| 141 | +|Android|BuildConfig.VERSION_NAME|String| |
| 142 | +|iOS|CFBundleShortVersionString|String| |
| 143 | +|Windows|Major.Minor.Build 例) "1.2.3"|String| |
| 144 | +|macOS(OS X)|CFBundleShortVersionString|String| |
| 145 | +|Browser|config.xml の widget 要素の version 属性の値が入ります|String| |
| 146 | +|Electron|config.xml の widget 要素の version 属性の値が入ります|String| |
| 147 | + |
| 148 | + |
| 149 | +### BuildInfo.versionCode |
| 150 | + |
| 151 | +Version Codeを取得します。 |
| 152 | +AndroidではINT型で提供されます。 |
| 153 | + |
| 154 | +|Platform|Value|Type| |
| 155 | +|--------|-----|----| |
| 156 | +|Android|BuildConfig.VERSION_CODE|int| |
| 157 | +|iOS|CFBundleVersion|string| |
| 158 | +|Windows|Major.Minor.Build.Revision 例) "1.2.3.4"|String| |
| 159 | +|macOS(OS X)|CFBundleVersion|string| |
| 160 | +|Browser|BuildInfo.version と同一|String| |
| 161 | +|Electron|BuildInfo.version と同一|String| |
| 162 | + |
| 163 | + |
| 164 | +### BuildInfo.debug |
| 165 | + |
| 166 | +デバッグビルドかどうかを取得します。 |
| 167 | + |
| 168 | +|Platform|Value|Type| |
| 169 | +|--------|-----|----| |
| 170 | +|Android|BuildConfig.DEBUG|Boolean| |
| 171 | +|iOS|defined "DEBUG" is true|Boolean| |
| 172 | +|Windows|isDevelopmentMode is true|Boolean| |
| 173 | +|Browser|常に false|Boolean| |
| 174 | +|Electron|```cordova build electron --debug``` とした場合 true となります|Boolean| |
| 175 | + |
| 176 | + |
| 177 | +### BuildInfo.buildType |
| 178 | + |
| 179 | +ビルドタイプを取得します。(AndroidおよびWindowsのみ) |
| 180 | + |
| 181 | +|Platform|Value|Type| |
| 182 | +|--------|-----|----| |
| 183 | +|Android|BuildConfig.BUILD_TYPE|String| |
| 184 | +|iOS|empty string|String| |
| 185 | +|Windows|"release" or "debug"|String| |
| 186 | +|macOS(OS X)|empty string|String| |
| 187 | +|Browser|empty string|String| |
| 188 | +|Electron|empty string|String| |
| 189 | + |
| 190 | + |
| 191 | +### BuildInfo.flavor |
| 192 | + |
| 193 | +フレーバーを取得します。(Androidのみ) |
| 194 | + |
| 195 | +|Platform|Value|Type| |
| 196 | +|--------|-----|----| |
| 197 | +|Android|BuildConfig.FLAVOR|String| |
| 198 | +|iOS|empty string|String| |
| 199 | +|Windows|empty string|String| |
| 200 | +|macOS(OS X)|empty string|String| |
| 201 | +|Browser|empty string|String| |
| 202 | +|Electron|empty string|String| |
| 203 | + |
| 204 | + |
| 205 | +### BuildInfo.buildDate |
| 206 | + |
| 207 | +Dateオブジェクトとしてビルド日時を取得します。 |
| 208 | + |
| 209 | +注意: |
| 210 | + |
| 211 | +- Aandroid: BuildInfo.gradeファイルをAndroidプロジェクトに追加します。 |
| 212 | + BuildInfo.gradeファイルは、BuildConfigクラスに_BUILDINFO_TIMESTAMPというプロパティを追加します。 |
| 213 | +- Windows: buildinfo.resjsonファイルをWindowsプロジェクトのstringsフォルダに追加します。 |
| 214 | + また、buildinfo.resjsonファイルはCordovaApp.projitemsファイルに追記されたタスクよにりビルド実行時に書き換えられます。 |
| 215 | +- Browser と Electron: ```cordova prepare``` が実行されたタイミングで |
| 216 | + platforms/browser/www/plugins/cordova-plugin-buildinfo/src/browser/BuildInfoProxy.js |
| 217 | + (または platforms/electron/www/plugins/cordova-plugin-buildinfo/src/browser/BuildInfoProxy.js) |
| 218 | + ファイル内にビルド日時を埋め込みます。 |
| 219 | + ```cordova prepare``` は、```cordova build```、```cordova run```、```cordova platform add```の場合も実行されます。 |
| 220 | + (参照: [Hooks Guide - Apache Cordova](https://cordova.apache.org/docs/en/9.x/guide/appdev/hooks/index.html)) |
| 221 | + |
| 222 | +|Platform|Value|Type| |
| 223 | +|--------|-----|----| |
| 224 | +|Android|BuildConfig.\_BUILDINFO\_TIMESTAMP value|Date| |
| 225 | +|iOS|メインバンドルのexecutionPathから取得したInfo.plistの更新日時|Date| |
| 226 | +|Windows|文字列リソースの "/buildinfo/Timestamp" 値を返します|Date| |
| 227 | +|macOS(OS X)|メインバンドルのリソースから取得したconfig.xmlの更新日時|Date| |
| 228 | +|Browser|```cordova prepare```が実行された日時|Date| |
| 229 | +|Electron|```cordova prepare```が実行された日時|Date| |
| 230 | + |
| 231 | + |
| 232 | +### BuildInfo.installDate |
| 233 | + |
| 234 | +Dateオブジェクトとしてインストール日時を返します |
| 235 | + |
| 236 | +注意: |
| 237 | +- Browser と Electron: インストール日時は不明です。 |
| 238 | + |
| 239 | +|Platform|Value|Type| |
| 240 | +|--------|-----|----| |
| 241 | +|Android|PackageInfoのfirstInstallTimeプロパティ|Date| |
| 242 | +|iOS|documentディレクトリの作成日時|Date| |
| 243 | +|Windows|Windows.ApplicatinoModel.Package.currentのinstalledDateプロパティ|Date| |
| 244 | +|macOS(OS X)|アプリケーションパッケージのFile Metadataに記録されている kMDItemDateAdded の日時|Date| |
| 245 | +|Browser|常に null|null| |
| 246 | +|Electron|常に null|null| |
| 247 | + |
| 248 | + |
| 249 | +### BuildInfo.windows |
| 250 | + |
| 251 | +Windowsのみ。 |
| 252 | + |
| 253 | +Windowsの追加情報を格納しています。 |
| 254 | + |
| 255 | +|Platform|Value|Type| |
| 256 | +|--------|-----|----| |
| 257 | +|Android|(未定義)|undefined| |
| 258 | +|iOS|(未定義)|undefined| |
| 259 | +|Windows|Object|Object| |
| 260 | +|macOS(OS X)|(未定義)|undefined| |
| 261 | +|Browser|(未定義)|undefined| |
| 262 | +|Electron|(未定義)|undefined| |
| 263 | + |
| 264 | +|Property name|Value|Type| |
| 265 | +|-------------|-----|----| |
| 266 | +|architecture|Windows.ApplicationModel.Package.current.id.architecture|integer| |
| 267 | +|description|Windows.ApplicationModel.Package.current.description|String| |
| 268 | +|displayName|Windows.ApplicationModel.Package.current.displayName|String| |
| 269 | +|familyName|Windows.ApplicationModel.Package.current.id.familyName|String| |
| 270 | +|fullName|Windows.ApplicationModel.Package.current.id.fullName|String| |
| 271 | +|logo|Object|Object| |
| 272 | +|publisher|Windows.ApplicationModel.Package.current.id.publisher|String| |
| 273 | +|publisherId|Windows.ApplicationModel.Package.current.id.publisherId|String| |
| 274 | +|publisherDisplayName|Windows.ApplicationModel.Package.current.publisherDisplayName|String| |
| 275 | +|resourceId|Windows.ApplicationModel.Package.current.id.resourceId|String| |
| 276 | +|version|Windows.ApplicationModel.Package.current.id.version|Object| |
| 277 | + |
| 278 | +#### BuildInfo.windows.logo |
| 279 | + |
| 280 | +|Property name|Value|Type| |
| 281 | +|-------------|-----|----| |
| 282 | +|absoluteCannonicalUri|Windows.ApplicationModel.Package.logo.absoluteCanonicalUri|String| |
| 283 | +|absoluteUri|Windows.ApplicationModel.Package.logo.absoluteUri|String| |
| 284 | +|displayIri|Windows.ApplicationModel.Package.logo.displayIri|String| |
| 285 | +|displayUri|Windows.ApplicationModel.Package.logo.displayUri|String| |
| 286 | +|path|Windows.ApplicationModel.Package.logo.path|String| |
| 287 | +|rawUri|Windows.ApplicationModel.Package.logo.rawUri|String| |
| 288 | + |
| 289 | +#### BuildInfo.windows.version |
| 290 | + |
| 291 | +|Property name|Value|Type| |
| 292 | +|-------------|-----|----| |
| 293 | +|major|Windows.ApplicationModel.Package.current.id.version.major|integer| |
| 294 | +|minor|Windows.ApplicationModel.Package.current.id.version.minor|integer| |
| 295 | +|build|Windows.ApplicationModel.Package.current.id.version.build|integer| |
| 296 | +|revision|Windows.ApplicationModel.Package.current.id.version.revision|integer| |
0 commit comments