This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,26 @@ + (NSURL *)getBundleUrl
2727{
2828 NSError *error;
2929 NSString *packageFolder = [CodePushPackage getCurrentPackageFolderPath: &error];
30+ NSURL *binaryJsBundleUrl = [[NSBundle mainBundle ] URLForResource: @" main" withExtension: @" jsbundle" ];
3031
3132 if (error || !packageFolder)
3233 {
33- return [[ NSBundle mainBundle ] URLForResource: @" main " withExtension: @" jsbundle " ] ;
34+ return binaryJsBundleUrl ;
3435 }
3536
3637 NSString *packageFile = [packageFolder stringByAppendingPathComponent: UpdateBundleFileName];
37- return [[NSURL alloc ] initFileURLWithPath: packageFile];
38+
39+ NSDictionary *binaryFileAttributes = [[NSFileManager defaultManager ] attributesOfItemAtPath: [binaryJsBundleUrl path ] error: nil ];
40+ NSDictionary *appFileAttribs = [[NSFileManager defaultManager ] attributesOfItemAtPath: packageFile error: nil ];
41+ NSDate *binaryDate = [binaryFileAttributes objectForKey: NSFileModificationDate ];
42+ NSDate *packageDate = [appFileAttribs objectForKey: NSFileModificationDate ];
43+
44+ if ([binaryDate compare: packageDate] == NSOrderedAscending) {
45+ // Return package file because it is newer than the app store binary's JS bundle
46+ return [[NSURL alloc ] initFileURLWithPath: packageFile];
47+ } else {
48+ return binaryJsBundleUrl;
49+ }
3850}
3951
4052// Internal API methods
You can’t perform that action at this time.
0 commit comments