diff --git a/CodePush.js b/CodePush.js index 58cf2e9..4c5cb83 100644 --- a/CodePush.js +++ b/CodePush.js @@ -1,7 +1,6 @@ import { AcquisitionManager as Sdk } from "code-push/script/acquisition-sdk"; import { Alert } from "./AlertAdapter"; import requestFetchAdapter from "./request-fetch-adapter"; -import semver from "semver"; import { Platform } from "react-native"; let NativeCodePush = require("react-native").NativeModules.CodePush; @@ -41,7 +40,7 @@ async function checkForUpdate(deploymentKey = null) { * in any updates for current app store version, regardless of hash. */ let queryPackage; - if (localPackage && localPackage.appVersion && semver.compare(localPackage.appVersion, config.appVersion) === 0) { + if (localPackage) { queryPackage = localPackage; } else { queryPackage = { appVersion: config.appVersion }; diff --git a/README.md b/README.md index 1b8acd6..2c0fdee 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ To let the CodePush runtime know which deployment it should query for updates ag ![Deployment list](https://cloud.githubusercontent.com/assets/116461/11601733/13011d5e-9a8a-11e5-9ce2-b100498ffb34.png) -2. In your app's `Info.plist` make sure your `Bundle versions string, short` (aka `CFBundleShortVersionString`) value is a valid [semver](http://semver.org/) version (e.g. 1.0.0 not 1.0) +2. In your app's `Info.plist` make sure your `Bundle versions string, short` (aka `CFBundleShortVersionString`) value is a valid [semver](http://semver.org/) version. Note that if the value provided is missing a patch version, the CodePush server will assume it is `0`, i.e. `1.0` will be treated as `1.0.0`. ![Bundle version](https://cloud.githubusercontent.com/assets/116461/12307416/f9b82688-b9f3-11e5-839a-f1c6b4acd093.png) @@ -269,7 +269,7 @@ After installing the plugin and syncing your Android Studio project with Gradle, } ``` -2. Ensure that the `android.defaultConfig.versionName` property in your `android/app/build.gradle` file is set to a semver compliant value (i.e. "1.0.0" not "1.0") +2. Ensure that the `android.defaultConfig.versionName` property in your `android/app/build.gradle` file is set to a semver compliant value. Note that if the value provided is missing a patch version, the CodePush server will assume it is `0`, i.e. `1.0` will be treated as `1.0.0`. ```gradle android { @@ -325,7 +325,7 @@ After installing the plugin and syncing your Android Studio project with Gradle, } ``` -2. Ensure that the `android.defaultConfig.versionName` property in your `android/app/build.gradle` file is set to a semver compliant value (i.e. "1.0.0" not "1.0") +2. Ensure that the `android.defaultConfig.versionName` property in your `android/app/build.gradle` file is set to a semver compliant value. Note that if the value provided is missing a patch version, the CodePush server will assume it is `0`, i.e. `1.0` will be treated as `1.0.0`. ```gradle android { diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java index 446e2bc..f28e118 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java @@ -162,7 +162,7 @@ public class CodePush { } else { // The binary version is newer. didUpdate = false; - if (!this.isDebugMode) { + if (!this.isDebugMode || !this.appVersion.equals(packageAppVersion)) { this.clearUpdates(); } diff --git a/ios/CodePush/CodePush.m b/ios/CodePush/CodePush.m index e21d4a3..b367f67 100644 --- a/ios/CodePush/CodePush.m +++ b/ios/CodePush/CodePush.m @@ -103,10 +103,15 @@ static NSString *bundleResourceName = @"main"; isRunningBinaryVersion = NO; return packageUrl; } else { + BOOL isRelease = NO; #ifndef DEBUG - [CodePush clearUpdates]; + isRelease = YES; #endif + if (isRelease || ![binaryAppVersion isEqualToString:packageAppVersion]) { + [CodePush clearUpdates]; + } + NSLog(logMessageFormat, binaryBundleURL); isRunningBinaryVersion = YES; return binaryBundleURL; diff --git a/package.json b/package.json index 333b82c..f49213b 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,9 @@ "url": "https://github.com/Microsoft/react-native-code-push" }, "dependencies": { - "code-push": "1.5.2-beta", - "semver": "^5.1.0" + "code-push": "1.5.2-beta" }, "devDependencies": { "react-native": "0.19.0" } -} \ No newline at end of file +}