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
27
27
{
28
28
NSError *error;
29
29
NSString *packageFolder = [CodePushPackage getCurrentPackageFolderPath: &error];
30
+ NSURL *binaryJsBundleUrl = [[NSBundle mainBundle ] URLForResource: @" main" withExtension: @" jsbundle" ];
30
31
31
32
if (error || !packageFolder)
32
33
{
33
- return [[ NSBundle mainBundle ] URLForResource: @" main " withExtension: @" jsbundle " ] ;
34
+ return binaryJsBundleUrl ;
34
35
}
35
36
36
37
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
+ }
38
50
}
39
51
40
52
// Internal API methods
You can’t perform that action at this time.
0 commit comments