diff --git a/bin/www/localPackage.js b/bin/www/localPackage.js
index 6402bcd..95f5791 100644
--- a/bin/www/localPackage.js
+++ b/bin/www/localPackage.js
@@ -37,7 +37,7 @@ var LocalPackage = (function (_super) {
}
var installError = function (error) {
CodePushUtil.invokeErrorCallback(error, errorCallback);
- Sdk.reportStatus(AcquisitionStatus.DeploymentFailed);
+ Sdk.reportStatus(AcquisitionStatus.DeploymentFailed, _this);
};
var newPackageLocation = LocalPackage.VersionsDir + "/" + this.packageHash;
var donePackageFileCopy = function (deployDir) {
@@ -100,7 +100,7 @@ var LocalPackage = (function (_super) {
}
};
var preInstallSuccess = function () {
- Sdk.reportStatus(AcquisitionStatus.DeploymentSucceeded);
+ Sdk.reportStatus(AcquisitionStatus.DeploymentSucceeded, _this);
invokeSuccessAndInstall();
};
var preInstallFailure = function (preInstallError) {
diff --git a/bin/www/sdk.js b/bin/www/sdk.js
index 5ee3d77..f65cb5e 100644
--- a/bin/www/sdk.js
+++ b/bin/www/sdk.js
@@ -10,6 +10,7 @@
///
///
+///
"use strict";
var NativeAppInfo = require("./nativeAppInfo");
var HttpRequester = require("./httpRequester");
@@ -19,7 +20,13 @@ var Sdk = (function () {
Sdk.getAcquisitionManager = function (callback, userDeploymentKey) {
var resolveManager = function (defaultInstance) {
if (userDeploymentKey) {
- var customConfiguration = { deploymentKey: userDeploymentKey, serverUrl: Sdk.DefaultConfiguration.serverUrl, ignoreAppVersion: Sdk.DefaultConfiguration.ignoreAppVersion };
+ var customConfiguration = {
+ deploymentKey: userDeploymentKey,
+ serverUrl: Sdk.DefaultConfiguration.serverUrl,
+ ignoreAppVersion: Sdk.DefaultConfiguration.ignoreAppVersion,
+ appVersion: Sdk.DefaultConfiguration.appVersion,
+ clientUniqueId: Sdk.DefaultConfiguration.clientUniqueId
+ };
var customAcquisitionManager = new AcquisitionManager(new HttpRequester(), customConfiguration);
callback(null, customAcquisitionManager);
}
@@ -33,26 +40,34 @@ var Sdk = (function () {
else {
NativeAppInfo.getServerURL(function (serverError, serverURL) {
NativeAppInfo.getDeploymentKey(function (depolymentKeyError, deploymentKey) {
- if (!serverURL || !deploymentKey) {
- callback(new Error("Could not get the CodePush configuration. Please check your config.xml file."), null);
- }
- else {
- Sdk.DefaultConfiguration = { deploymentKey: deploymentKey, serverUrl: serverURL, ignoreAppVersion: false };
- Sdk.DefaultAcquisitionManager = new AcquisitionManager(new HttpRequester(), Sdk.DefaultConfiguration);
- resolveManager(Sdk.DefaultAcquisitionManager);
- }
+ NativeAppInfo.getApplicationVersion(function (appVersionError, appVersion) {
+ if (!serverURL || !deploymentKey || !appVersion) {
+ callback(new Error("Could not get the CodePush configuration. Please check your config.xml file."), null);
+ }
+ else {
+ Sdk.DefaultConfiguration = {
+ deploymentKey: deploymentKey,
+ serverUrl: serverURL,
+ ignoreAppVersion: false,
+ appVersion: appVersion,
+ clientUniqueId: device.uuid
+ };
+ Sdk.DefaultAcquisitionManager = new AcquisitionManager(new HttpRequester(), Sdk.DefaultConfiguration);
+ resolveManager(Sdk.DefaultAcquisitionManager);
+ }
+ });
});
});
}
};
- Sdk.reportStatus = function (status, callback) {
+ Sdk.reportStatus = function (status, pkg, callback) {
try {
Sdk.getAcquisitionManager(function (error, acquisitionManager) {
if (error) {
callback && callback(error, null);
}
else {
- acquisitionManager.reportStatus(status, null, callback);
+ acquisitionManager.reportStatusDeploy(pkg, status, callback);
}
});
}
diff --git a/package.json b/package.json
index 2f11589..585ab48 100644
--- a/package.json
+++ b/package.json
@@ -22,11 +22,12 @@
"cordova-ios"
],
"peerDependencies": {
- "code-push": ">=1.0.0-beta",
+ "code-push": ">=1.5.0-beta",
"cordova-plugin-file-transfer": ">=1.3.0",
"cordova-plugin-file": ">=3.0.0",
"cordova-plugin-zip": ">=3.0.0",
- "cordova-plugin-dialogs": ">=1.1.1"
+ "cordova-plugin-dialogs": ">=1.1.1",
+ "cordova-plugin-device": ">=1.1.0"
},
"author": "Microsoft Corporation",
"license": "Licensed under the MIT license.",
diff --git a/plugin.xml b/plugin.xml
index 518fa23..87dd00a 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -6,11 +6,12 @@
cordova,code,push
https://github.com/Microsoft/cordova-plugin-code-push.git
-
+
+
diff --git a/typings/codePush.d.ts b/typings/codePush.d.ts
index 23a0c75..ca9213f 100644
--- a/typings/codePush.d.ts
+++ b/typings/codePush.d.ts
@@ -136,9 +136,11 @@ interface SuccessCallback { (result?: T): void; }
interface ErrorCallback { (error?: Error): void; }
interface Configuration {
- serverUrl: string;
+ appVersion: string;
+ clientUniqueId: string;
deploymentKey: string;
- ignoreAppVersion?: boolean;
+ serverUrl: string;
+ ignoreAppVersion?: boolean
}
declare class AcquisitionStatus {
@@ -149,7 +151,7 @@ declare class AcquisitionStatus {
declare class AcquisitionManager {
constructor(httpRequester: Http.Requester, configuration: Configuration);
public queryUpdateWithCurrentPackage(currentPackage: IPackage, callback?: Callback): void;
- public reportStatus(status: string, message?: string, callback?: Callback): void;
+ public reportStatusDeploy(pkg?: IPackage, status?: string, callback?: Callback): void;
}
interface CodePushCordovaPlugin {
diff --git a/typings/device.d.ts b/typings/device.d.ts
new file mode 100644
index 0000000..1abb375
--- /dev/null
+++ b/typings/device.d.ts
@@ -0,0 +1,34 @@
+// Type definitions for Apache Cordova Device plugin.
+// Project: https://github.com/apache/cordova-plugin-device
+// Definitions by: Microsoft Open Technologies, Inc.
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+//
+// Copyright (c) Microsoft Open Technologies, Inc.
+// Licensed under the MIT license.
+
+/**
+ * This plugin defines a global device object, which describes the device's hardware and software.
+ * Although the object is in the global scope, it is not available until after the deviceready event.
+ */
+interface Device {
+ /** Get the version of Cordova running on the device. */
+ cordova: string;
+ /**
+ * The device.model returns the name of the device's model or product. The value is set
+ * by the device manufacturer and may be different across versions of the same product.
+ */
+ model: string;
+ /** Get the device's operating system name. */
+ platform: string;
+ /** Get the device's Universally Unique Identifier (UUID). */
+ uuid: string;
+ /** Get the operating system version. */
+ version: string;
+ /** Get the device's manufacturer. */
+ manufacturer: string;
+ /** Whether the device is running on a simulator. */
+ isVirtual: boolean;
+ /** Get the device hardware serial number. */
+ serial: string;}
+
+declare var device: Device;
\ No newline at end of file
diff --git a/www/localPackage.ts b/www/localPackage.ts
index 0a19ba0..8bc5f37 100644
--- a/www/localPackage.ts
+++ b/www/localPackage.ts
@@ -61,7 +61,7 @@ class LocalPackage extends Package implements ILocalPackage {
var installError: ErrorCallback = (error: Error): void => {
CodePushUtil.invokeErrorCallback(error, errorCallback);
- Sdk.reportStatus(AcquisitionStatus.DeploymentFailed);
+ Sdk.reportStatus(AcquisitionStatus.DeploymentFailed, this);
};
var newPackageLocation = LocalPackage.VersionsDir + "/" + this.packageHash;
@@ -128,7 +128,7 @@ class LocalPackage extends Package implements ILocalPackage {
};
var preInstallSuccess = () => {
- Sdk.reportStatus(AcquisitionStatus.DeploymentSucceeded);
+ Sdk.reportStatus(AcquisitionStatus.DeploymentSucceeded, this);
/* package will be cleaned up after success, on the native side */
invokeSuccessAndInstall();
};
diff --git a/www/sdk.ts b/www/sdk.ts
index 8c02aef..105b4c3 100644
--- a/www/sdk.ts
+++ b/www/sdk.ts
@@ -1,5 +1,6 @@
///
///
+///
"use strict";
@@ -21,7 +22,13 @@ class Sdk {
var resolveManager = (defaultInstance: AcquisitionManager): void => {
if (userDeploymentKey) {
- var customConfiguration: Configuration = { deploymentKey: userDeploymentKey, serverUrl: Sdk.DefaultConfiguration.serverUrl, ignoreAppVersion: Sdk.DefaultConfiguration.ignoreAppVersion };
+ var customConfiguration: Configuration = {
+ deploymentKey: userDeploymentKey,
+ serverUrl: Sdk.DefaultConfiguration.serverUrl,
+ ignoreAppVersion: Sdk.DefaultConfiguration.ignoreAppVersion,
+ appVersion: Sdk.DefaultConfiguration.appVersion,
+ clientUniqueId: Sdk.DefaultConfiguration.clientUniqueId
+ };
var customAcquisitionManager: AcquisitionManager = new AcquisitionManager(new HttpRequester(), customConfiguration);
callback(null, customAcquisitionManager);
} else {
@@ -34,13 +41,21 @@ class Sdk {
} else {
NativeAppInfo.getServerURL((serverError: Error, serverURL: string) => {
NativeAppInfo.getDeploymentKey((depolymentKeyError: Error, deploymentKey: string) => {
- if (!serverURL || !deploymentKey) {
- callback(new Error("Could not get the CodePush configuration. Please check your config.xml file."), null);
- } else {
- Sdk.DefaultConfiguration = { deploymentKey: deploymentKey, serverUrl: serverURL, ignoreAppVersion: false };
- Sdk.DefaultAcquisitionManager = new AcquisitionManager(new HttpRequester(), Sdk.DefaultConfiguration);
- resolveManager(Sdk.DefaultAcquisitionManager);
- }
+ NativeAppInfo.getApplicationVersion((appVersionError: Error, appVersion: string) => {
+ if (!serverURL || !deploymentKey || !appVersion) {
+ callback(new Error("Could not get the CodePush configuration. Please check your config.xml file."), null);
+ } else {
+ Sdk.DefaultConfiguration = {
+ deploymentKey: deploymentKey,
+ serverUrl: serverURL,
+ ignoreAppVersion: false,
+ appVersion: appVersion,
+ clientUniqueId: device.uuid
+ };
+ Sdk.DefaultAcquisitionManager = new AcquisitionManager(new HttpRequester(), Sdk.DefaultConfiguration);
+ resolveManager(Sdk.DefaultAcquisitionManager);
+ }
+ });
});
});
}
@@ -49,14 +64,14 @@ class Sdk {
/**
* Reports the update status to the CodePush server.
*/
- public static reportStatus(status: string, callback?: Callback) {
+ public static reportStatus(status: string, pkg: IPackage, callback?: Callback) {
try {
Sdk.getAcquisitionManager((error: Error, acquisitionManager: AcquisitionManager) => {
if (error) {
callback && callback(error, null);
}
else {
- acquisitionManager.reportStatus(status, null, callback);
+ acquisitionManager.reportStatusDeploy(pkg, status, callback);
}
});
} catch (e) {