diff --git a/Examples/HybridMobileDeployCompanion/index.ios.js b/Examples/HybridMobileDeployCompanion/index.ios.js index 49ad592..7127508 100644 --- a/Examples/HybridMobileDeployCompanion/index.ios.js +++ b/Examples/HybridMobileDeployCompanion/index.ios.js @@ -22,9 +22,9 @@ var HybridMobileDeployCompanion = React.createClass({ this.fetchData(); }, fetchData: function() { - HybridMobileDeploy.queryUpdate((err, update) => { - this.setState({ update: update, updateString: JSON.stringify(update) }); - }); + HybridMobileDeploy.queryUpdate((err, update) => { + this.setState({ update: update, updateString: JSON.stringify(update) }); + }); }, getInitialState: function() { return { update: false, updateString: "" }; diff --git a/HybridMobileDeploy.ios.js b/HybridMobileDeploy.ios.js index dff99dd..159eaf7 100644 --- a/HybridMobileDeploy.ios.js +++ b/HybridMobileDeploy.ios.js @@ -45,15 +45,18 @@ function queryUpdate(callback) { getSdk(function(err, sdk) { if (err) callback(err); NativeHybridMobileDeploy.getLocalPackage(function(err, localPackage) { + var defaultPackage = {appVersion: configuration.appVersion}; if (err) { console.log(err); - var pkg = {appVersion: configuration.appVersion}; - sdk.queryUpdateWithCurrentPackage(pkg, callback); + sdk.queryUpdateWithCurrentPackage(defaultPackage, callback); } else if (localPackage == null) { - var pkg = {appVersion: configuration.appVersion}; - sdk.queryUpdateWithCurrentPackage(pkg, callback); + sdk.queryUpdateWithCurrentPackage(defaultPackage, callback); } else { - sdk.queryUpdateWithCurrentPackage(localPackage, callback); + if (localPackage.appVersion !== configuration.appVersion) { + sdk.queryUpdateWithCurrentPackage(defaultPackage, callback) + } else { + sdk.queryUpdateWithCurrentPackage(localPackage, callback); + } } }); }); @@ -61,7 +64,7 @@ function queryUpdate(callback) { } function installUpdate(update) { - // use the downloaded package info. native code will save the package info + // Use the downloaded package info. Native code will save the package info // so that the client knows what the current package version is. NativeHybridMobileDeploy.installUpdate(update, JSON.stringify(update), (err) => console.log(err)); } diff --git a/HybridMobileDeploy.m b/HybridMobileDeploy.m index 9bde395..c640ba7 100644 --- a/HybridMobileDeploy.m +++ b/HybridMobileDeploy.m @@ -87,7 +87,6 @@ RCT_EXPORT_METHOD(installUpdate:(NSDictionary*)updatePackage NSString *updateContents = [[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&err]; - if (err) { // TODO send download url callback(@[RCTMakeError(@"Error downloading url", err, [[NSDictionary alloc] initWithObjectsAndKeys:[url absoluteString],@"updateUrl", nil])]); @@ -139,7 +138,6 @@ RCT_EXPORT_METHOD(getLocalPackage: (RCTResponseSenderBlock)callback) dispatch_async(dispatch_get_main_queue(), ^{ NSError* readError; - NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&readError]; if (readError) { callback(@[RCTMakeError(@"Error finding local package ", readError, [[NSDictionary alloc] initWithObjectsAndKeys:path,@"packagePath", nil]), [NSNull null]]); @@ -155,7 +153,6 @@ RCT_EXPORT_METHOD(getLocalPackage: (RCTResponseSenderBlock)callback) callback(@[[NSNull null], json]); } } - }); }