@@ -50,7 +50,10 @@ + (NSURL *)bundleURLForResource:(NSString *)resourceName
5050 NSString *packageFile = [CodePushPackage getCurrentPackageBundlePath: &error];
5151 NSURL *binaryJsBundleUrl = [[NSBundle mainBundle ] URLForResource: resourceName withExtension: resourceExtension];
5252
53+ NSString *logMessageFormat = @" Loading JS bundle from %@ " ;
54+
5355 if (error || !packageFile) {
56+ NSLog (logMessageFormat, binaryJsBundleUrl);
5457 return binaryJsBundleUrl;
5558 }
5659
@@ -61,8 +64,11 @@ + (NSURL *)bundleURLForResource:(NSString *)resourceName
6164
6265 if ([binaryDate compare: packageDate] == NSOrderedAscending) {
6366 // Return package file because it is newer than the app store binary's JS bundle
64- return [[NSURL alloc ] initFileURLWithPath: packageFile];
67+ NSURL *packageUrl = [[NSURL alloc ] initFileURLWithPath: packageFile];
68+ NSLog (logMessageFormat, packageUrl);
69+ return packageUrl;
6570 } else {
71+ NSLog (logMessageFormat, binaryJsBundleUrl);
6672 return binaryJsBundleUrl;
6773 }
6874}
@@ -159,6 +165,7 @@ - (void)initializeUpdateAfterRestart
159165 if (updateIsLoading) {
160166 // Pending update was initialized, but notifyApplicationReady was not called.
161167 // Therefore, deduce that it is a broken update and rollback.
168+ NSLog (@" Update did not finish loading the last time, rolling back to a previous version." );
162169 [self rollbackPackage ];
163170 } else {
164171 // Mark that we tried to initialize the new update, so that if it crashes,
@@ -214,8 +221,7 @@ - (void)loadBundle
214221 // file (since Chrome wouldn't support it). Otherwise, update
215222 // the current bundle URL to point at the latest update
216223 if ([CodePush isUsingTestConfiguration ] || ![_bridge.bundleURL.scheme hasPrefix: @" http" ]) {
217- NSURL *url = [CodePush bundleURL ];
218- _bridge.bundleURL = url;
224+ _bridge.bundleURL = [CodePush bundleURL ];
219225 }
220226
221227 [_bridge reload ];
@@ -386,17 +392,15 @@ - (void)savePendingUpdate:(NSString *)packageHash
386392 [self savePendingUpdate: updatePackage[PackageHashKey]
387393 isLoading: NO ];
388394
389- if (installMode == CodePushInstallModeOnNextResume) {
395+ if (installMode == CodePushInstallModeOnNextResume && !_hasResumeListener ) {
390396 // Ensure we do not add the listener twice.
391- if (!_hasResumeListener) {
392- // Register for app resume notifications so that we
393- // can check for pending updates which support "restart on resume"
394- [[NSNotificationCenter defaultCenter ] addObserver: self
395- selector: @selector (loadBundle )
396- name: UIApplicationWillEnterForegroundNotification
397- object: [UIApplication sharedApplication ]];
398- _hasResumeListener = YES ;
399- }
397+ // Register for app resume notifications so that we
398+ // can check for pending updates which support "restart on resume"
399+ [[NSNotificationCenter defaultCenter ] addObserver: self
400+ selector: @selector (loadBundle )
401+ name: UIApplicationWillEnterForegroundNotification
402+ object: [UIApplication sharedApplication ]];
403+ _hasResumeListener = YES ;
400404 }
401405 // Signal to JS that the update has been applied.
402406 resolve (nil );
@@ -453,8 +457,9 @@ - (void)savePendingUpdate:(NSString *)packageHash
453457
454458/*
455459 * This method is the native side of the CodePush.downloadAndReplaceCurrentBundle()
456- * method, which is only to be used during tests and no-ops if the test configuration
457- * flag is not set.
460+ * method, which replaces the current bundle with the one downloaded from
461+ * removeBundleUrl. It is only to be used during tests and no-ops if the test
462+ * configuration flag is not set.
458463 */
459464RCT_EXPORT_METHOD (downloadAndReplaceCurrentBundle:(NSString *)remoteBundleUrl)
460465{
0 commit comments