@@ -18,13 +18,13 @@ @implementation CodePush {
18
18
static BOOL testConfigurationFlag = NO ;
19
19
20
20
// These constants represent valid deployment statuses
21
- static NSString *const DeploymentSucceeded = @" DeploymentSucceeded" ;
22
21
static NSString *const DeploymentFailed = @" DeploymentFailed" ;
22
+ static NSString *const DeploymentSucceeded = @" DeploymentSucceeded" ;
23
23
24
24
// These keys represent the names we use to store data in NSUserDefaults
25
25
static NSString *const FailedUpdatesKey = @" CODE_PUSH_FAILED_UPDATES" ;
26
- static NSString *const PendingUpdateKey = @" CODE_PUSH_PENDING_UPDATE" ;
27
26
static NSString *const LastDeploymentReportKey = @" CODE_PUSH_LAST_DEPLOYMENT_REPORT" ;
27
+ static NSString *const PendingUpdateKey = @" CODE_PUSH_PENDING_UPDATE" ;
28
28
29
29
// These keys are already "namespaced" by the PendingUpdateKey, so
30
30
// their values don't need to be obfuscated to prevent collision with app data
@@ -552,29 +552,22 @@ - (void)savePendingUpdate:(NSString *)packageHash
552
552
} else if (_isFirstRunAfterUpdate) {
553
553
// Check if the current CodePush package has been reported
554
554
NSError *error;
555
- NSDictionary * currentPackage = [CodePushPackage getCurrentPackage: &error];
556
- if (currentPackage) {
557
- NSString * currentPackageIdentifier = [self getPackageStatusReportIdentifier: currentPackage];
555
+ NSDictionary * currentPackage = [CodePushPackage getCurrentPackage: &error];
556
+ if (!error && currentPackage) {
557
+ NSString * currentPackageIdentifier = [self getPackageStatusReportIdentifier: currentPackage];
558
558
if (currentPackageIdentifier && [self isDeploymentStatusNotYetReported: currentPackageIdentifier]) {
559
559
[self recordDeploymentStatusReported: currentPackageIdentifier];
560
560
resolve (@{ @" package" : currentPackage, @" status" : DeploymentSucceeded });
561
561
return ;
562
562
}
563
563
}
564
- } else {
565
- if (isRunningBinaryVersion) {
566
- // Check if the current appVersion has been reported. Use date as the binary identifier to
567
- // handle binary releases that do not modify the appVersion.
568
- NSURL *binaryJsBundleUrl = [CodePush bundleURL ];
569
- NSDictionary *binaryFileAttributes = [[NSFileManager defaultManager ] attributesOfItemAtPath: [binaryJsBundleUrl path ] error: nil ];
570
- NSTimeInterval binaryDate = [[binaryFileAttributes objectForKey: NSFileModificationDate ] timeIntervalSince1970 ];
571
- NSString * binaryIdentifier = [NSString stringWithFormat: @" %f " , binaryDate];
572
-
573
- if ([self isDeploymentStatusNotYetReported: binaryIdentifier]) {
574
- [self recordDeploymentStatusReported: binaryIdentifier];
575
- resolve (@{ @" appVersion" : [[CodePushConfig current ] appVersion ] });
576
- return ;
577
- }
564
+ } else if (isRunningBinaryVersion || [_bridge.bundleURL.scheme hasPrefix: @" http" ]) {
565
+ // Check if the current appVersion has been reported.
566
+ NSString *appVersion = [[CodePushConfig current ] appVersion ];
567
+ if ([self isDeploymentStatusNotYetReported: appVersion]) {
568
+ [self recordDeploymentStatusReported: appVersion];
569
+ resolve (@{ @" appVersion" : appVersion });
570
+ return ;
578
571
}
579
572
}
580
573
0 commit comments