CR feedback

This commit is contained in:
Geoffrey Goh
2016-04-20 09:53:12 -07:00
parent 96c629d0a1
commit 7a3ba2efa4

View File

@@ -172,6 +172,29 @@ static NSString *bundleResourceName = @"main";
@synthesize bridge = _bridge;
@synthesize methodQueue = _methodQueue;
/*
* This method is used to clear updates that are installed
* under a different app version and hence don't apply anymore,
* during a debug run configuration and when the bridge is
* running the JS bundle from the dev server.
*/
- (void)clearDebugUpdates
{
dispatch_async(dispatch_get_main_queue(), ^{
if ([_bridge.bundleURL.scheme hasPrefix:@"http"]) {
NSError *error;
NSString *binaryAppVersion = [[CodePushConfig current] appVersion];
NSDictionary *currentPackageMetadata = [CodePushPackage getCurrentPackage:&error];
if (currentPackageMetadata) {
NSString *packageAppVersion = [currentPackageMetadata objectForKey:AppVersionKey];
if (![binaryAppVersion isEqualToString:packageAppVersion]) {
[CodePush clearUpdates];
}
}
}
});
}
/*
* This method is used by the React Native bridge to allow
* our plugin to expose constants to the JS-side. In our case
@@ -240,23 +263,6 @@ static NSString *bundleResourceName = @"main";
return self;
}
- (void)clearDebugUpdates
{
dispatch_async(dispatch_get_main_queue(), ^{
if ([_bridge.bundleURL.scheme hasPrefix:@"http"]) {
NSError *error;
NSString *binaryAppVersion = [[CodePushConfig current] appVersion];
NSDictionary *currentPackageMetadata = [CodePushPackage getCurrentPackage:&error];
if (currentPackageMetadata) {
NSString *packageAppVersion = [currentPackageMetadata objectForKey:AppVersionKey];
if (![binaryAppVersion isEqualToString:packageAppVersion]) {
[CodePush clearUpdates];
}
}
}
});
}
/*
* This method is used when the app is started to either
* initialize a pending update or rollback a faulty update
@@ -264,7 +270,9 @@ static NSString *bundleResourceName = @"main";
*/
- (void)initializeUpdateAfterRestart
{
#ifdef DEBUG
[self clearDebugUpdates];
#endif
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
NSDictionary *pendingUpdate = [preferences objectForKey:PendingUpdateKey];