From cf2daafba8b0533c6c611fb1fc2bbf3f61c58062 Mon Sep 17 00:00:00 2001 From: sefa said Date: Mon, 16 Dec 2019 09:39:02 +0300 Subject: [PATCH] added update type and can be access from app --- www/codePush.ts | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/www/codePush.ts b/www/codePush.ts index ff62797c..07f7324b 100644 --- a/www/codePush.ts +++ b/www/codePush.ts @@ -46,10 +46,28 @@ class CodePush implements CodePushCordovaPlugin { * @param notifySucceeded Optional callback invoked if the plugin was successfully notified. * @param notifyFailed Optional callback invoked in case of an error during notifying the plugin. */ + public notifyApplicationReady(notifySucceeded?: SuccessCallback, notifyFailed?: ErrorCallback): void { cordova.exec(notifySucceeded, notifyFailed, "CodePush", "notifyApplicationReady", []); } + /** + * Do full update or diff update + * 0 = diff update + * 1 = full update + */ + + private UpdateType: Number = 0; + /** + * + * @param type + * Implement for full update prefence + */ + public setUpdateType(type: Number): void { + this.UpdateType = type; + } + + /** * Reloads the application. If there is a pending update package installed using ON_NEXT_RESTART or ON_NEXT_RESUME modes, the update * will be immediately visible to the user. Otherwise, calling this function will simply reload the current version of the application. @@ -63,14 +81,14 @@ class CodePush implements CodePushCordovaPlugin { * !!! This function is called from the native side, please make changes accordingly. !!! */ public reportStatus(status: number, label: string, appVersion: string, deploymentKey: string, previousLabelOrAppVersion?: string, previousDeploymentKey?: string) { - if (((!label && appVersion === previousLabelOrAppVersion) || label === previousLabelOrAppVersion) - && deploymentKey === previousDeploymentKey) { - // No-op since the new appVersion and label is exactly the same as the previous - // (the app might have been updated via a direct or HockeyApp deployment). - return; - } - - var createPackageForReporting = (label: string, appVersion: string): IPackage => { + if (((!label && appVersion === previousLabelOrAppVersion) || label === previousLabelOrAppVersion) + && deploymentKey === previousDeploymentKey) { + // No-op since the new appVersion and label is exactly the same as the previous + // (the app might have been updated via a direct or HockeyApp deployment). + return; + } + + var createPackageForReporting = (label: string, appVersion: string): IPackage => { return { /* The SDK only reports the label and appVersion. The rest of the properties are added for type safety. */ @@ -199,7 +217,10 @@ class CodePush implements CodePushCordovaPlugin { LocalPackage.getCurrentOrDefaultPackage((localPackage: LocalPackage) => { NativeAppInfo.getApplicationVersion((appVersionError: Error, currentBinaryVersion: string) => { if (!appVersionError) { - localPackage.appVersion = currentBinaryVersion; + localPackage.appVersion = currentBinaryVersion; + } + if (this.UpdateType === 1) { + delete localPackage.label; } CodePushUtil.logMessage("Checking for update."); acquisitionManager.queryUpdateWithCurrentPackage(localPackage, callback);