Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add appBuild to device getInfo #1994

Merged
merged 1 commit into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void getInfo(PluginCall call) {
r.put("model", android.os.Build.MODEL);
r.put("osVersion", android.os.Build.VERSION.RELEASE);
r.put("appVersion", getAppVersion());
r.put("appBuild", getAppBuild());
r.put("platform", getPlatform());
r.put("manufacturer", android.os.Build.MANUFACTURER);
r.put("uuid", getUuid());
Expand Down Expand Up @@ -72,6 +73,15 @@ private String getAppVersion() {
}
}

private String getAppBuild() {
try {
PackageInfo pinfo = getContext().getPackageManager().getPackageInfo(getContext().getPackageName(), 0);
return Integer.toString(pinfo.versionCode);
} catch(Exception ex) {
return null;
}
}

private String getPlatform() {
return "android";
}
Expand Down
4 changes: 4 additions & 0 deletions core/src/core-plugin-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ export interface DeviceInfo {
* The current bundle verison of the app
*/
appVersion: string;
/**
* The current bundle build of the app
*/
appBuild: string;
/**
* The version of the device OS
*/
Expand Down
1 change: 1 addition & 0 deletions core/src/web/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class DevicePluginWeb extends WebPlugin implements DevicePlugin {
model: uaFields.model,
platform: <'web'> 'web',
appVersion: '',
appBuild: '',
osVersion: uaFields.osVersion,
manufacturer: navigator.vendor,
isVirtual: false,
Expand Down
1 change: 1 addition & 0 deletions electron/src/electron/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class DevicePluginElectron extends WebPlugin implements DevicePlugin {
model: info.model,
platform: <'electron'> 'electron',
appVersion: '',
appBuild: '',
osVersion: info.osVersion,
manufacturer: navigator.vendor,
isVirtual: false,
Expand Down
1 change: 1 addition & 0 deletions ios/Capacitor/Capacitor/Plugins/Device.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class CAPDevicePlugin: CAPPlugin {
"model": UIDevice.current.model,
"osVersion": UIDevice.current.systemVersion,
"appVersion": Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "",
"appBuild": Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "",
"platform": "ios",
"manufacturer": "Apple",
"uuid": UIDevice.current.identifierForVendor!.uuidString,
Expand Down
1 change: 1 addition & 0 deletions site/docs-md/apis/device/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ console.log(info);
{
"diskFree": 12228108288,
"appVersion": "1.0.2",
"appBuild": "123",
"osVersion": "11.2",
"platform": "ios",
"memUsed": 93851648,
Expand Down
8 changes: 8 additions & 0 deletions site/src/assets/docs-content/apis/device/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ <h4 class="avc-code-interface-name">DeviceInfo</h4>
</div>


<div class="avc-code-interface-param">
<div class="avc-code-param-comment">// The current bundle build of the app</div>
<div class="avc-code-line"><span class="avc-code-param-name">appBuild</span>
:
<avc-code-type>string</avc-code-type>;
</div>
</div>

<div class="avc-code-interface-param">
<div class="avc-code-param-comment">// The current bundle verison of the app</div>
<div class="avc-code-line"><span class="avc-code-param-name">appVersion</span>
Expand Down