@@ -18,13 +18,13 @@ @implementation CodePush {
1818static BOOL testConfigurationFlag = NO ;
1919
2020// These constants represent valid deployment statuses
21- static NSString *const DeploymentSucceeded = @" DeploymentSucceeded" ;
2221static NSString *const DeploymentFailed = @" DeploymentFailed" ;
22+ static NSString *const DeploymentSucceeded = @" DeploymentSucceeded" ;
2323
2424// These keys represent the names we use to store data in NSUserDefaults
2525static NSString *const FailedUpdatesKey = @" CODE_PUSH_FAILED_UPDATES" ;
26- static NSString *const PendingUpdateKey = @" CODE_PUSH_PENDING_UPDATE" ;
2726static NSString *const LastDeploymentReportKey = @" CODE_PUSH_LAST_DEPLOYMENT_REPORT" ;
27+ static NSString *const PendingUpdateKey = @" CODE_PUSH_PENDING_UPDATE" ;
2828
2929// These keys are already "namespaced" by the PendingUpdateKey, so
3030// their values don't need to be obfuscated to prevent collision with app data
@@ -552,29 +552,22 @@ - (void)savePendingUpdate:(NSString *)packageHash
552552 } else if (_isFirstRunAfterUpdate) {
553553 // Check if the current CodePush package has been reported
554554 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];
558558 if (currentPackageIdentifier && [self isDeploymentStatusNotYetReported: currentPackageIdentifier]) {
559559 [self recordDeploymentStatusReported: currentPackageIdentifier];
560560 resolve (@{ @" package" : currentPackage, @" status" : DeploymentSucceeded });
561561 return ;
562562 }
563563 }
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 ;
578571 }
579572 }
580573
0 commit comments