From 87e15c79b5614b4cb2dccdf86b0b045400d2d7fe Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Sun, 13 Mar 2016 21:30:33 -0700 Subject: [PATCH] Re-organizing methods --- ios/CodePush/CodePush.m | 58 +++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/ios/CodePush/CodePush.m b/ios/CodePush/CodePush.m index 55b8675..7b69dc2 100644 --- a/ios/CodePush/CodePush.m +++ b/ios/CodePush/CodePush.m @@ -438,7 +438,7 @@ static NSString *bundleResourceName = @"main"; _lastResignedDate = [NSDate date]; } -#pragma mark - JavaScript-exported module methods +#pragma mark - JavaScript-exported module methods (Public) /* * This is native-side of the RemotePackage.download method @@ -485,7 +485,7 @@ RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary*)updatePackage // The download failed failCallback:^(NSError *err) { dispatch_async(_methodQueue, ^{ - if ([CodePushPackage isCodePushError:err]) { + if ([CodePushErrorUtils isCodePushError:err]) { [self saveFailedUpdate:mutableUpdatePackage]; } @@ -648,6 +648,33 @@ RCT_EXPORT_METHOD(notifyApplicationReady:(RCTPromiseResolveBlock)resolve resolve(nil); } +/* + * This method is the native side of the CodePush.restartApp() method. + */ +RCT_EXPORT_METHOD(restartApp:(BOOL)onlyIfUpdateIsPending) +{ + // If this is an unconditional restart request, or there + // is current pending update, then reload the app. + if (!onlyIfUpdateIsPending || [self isPendingUpdate:nil]) { + [self loadBundle]; + } +} + +#pragma mark - JavaScript-exported module methods (Private) + +/* + * This method is the native side of the CodePush.downloadAndReplaceCurrentBundle() + * method, which replaces the current bundle with the one downloaded from + * removeBundleUrl. It is only to be used during tests and no-ops if the test + * configuration flag is not set. + */ +RCT_EXPORT_METHOD(downloadAndReplaceCurrentBundle:(NSString *)remoteBundleUrl) +{ + if ([CodePush isUsingTestConfiguration]) { + [CodePushPackage downloadAndReplaceCurrentBundle:remoteBundleUrl]; + } +} + /* * This method is checks if a new status update exists (new version was installed, * or an update failed) and return its details (version label, status). @@ -682,29 +709,4 @@ RCT_EXPORT_METHOD(getNewStatusReport:(RCTPromiseResolveBlock)resolve resolve(nil); } -/* - * This method is the native side of the CodePush.restartApp() method. - */ -RCT_EXPORT_METHOD(restartApp:(BOOL)onlyIfUpdateIsPending) -{ - // If this is an unconditional restart request, or there - // is current pending update, then reload the app. - if (!onlyIfUpdateIsPending || [self isPendingUpdate:nil]) { - [self loadBundle]; - } -} - -/* - * This method is the native side of the CodePush.downloadAndReplaceCurrentBundle() - * method, which replaces the current bundle with the one downloaded from - * removeBundleUrl. It is only to be used during tests and no-ops if the test - * configuration flag is not set. - */ -RCT_EXPORT_METHOD(downloadAndReplaceCurrentBundle:(NSString *)remoteBundleUrl) -{ - if ([CodePush isUsingTestConfiguration]) { - [CodePushPackage downloadAndReplaceCurrentBundle:remoteBundleUrl]; - } -} - -@end +@end \ No newline at end of file