Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 2d5d80f

Browse files
committed
fix issue with packager
1 parent aec64cc commit 2d5d80f

File tree

4 files changed

+30
-39
lines changed

4 files changed

+30
-39
lines changed

CodePush.m

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ @implementation CodePush {
1818
static BOOL testConfigurationFlag = NO;
1919

2020
// These constants represent valid deployment statuses
21-
static NSString *const DeploymentSucceeded = @"DeploymentSucceeded";
2221
static NSString *const DeploymentFailed = @"DeploymentFailed";
22+
static NSString *const DeploymentSucceeded = @"DeploymentSucceeded";
2323

2424
// These keys represent the names we use to store data in NSUserDefaults
2525
static NSString *const FailedUpdatesKey = @"CODE_PUSH_FAILED_UPDATES";
26-
static NSString *const PendingUpdateKey = @"CODE_PUSH_PENDING_UPDATE";
2726
static 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

CodePushConfig.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ - (instancetype)init
3333
NSString *deploymentKey = [infoDictionary objectForKey:@"CodePushDeploymentKey"];
3434
NSString *serverURL = [infoDictionary objectForKey:@"CodePushServerURL"];
3535

36-
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
37-
NSString* clientUniqueId = [userDefaults stringForKey:ClientUniqueIDConfigKey];
36+
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
37+
NSString *clientUniqueId = [userDefaults stringForKey:ClientUniqueIDConfigKey];
3838
if (clientUniqueId == nil) {
3939
clientUniqueId = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
4040
[userDefaults setObject:clientUniqueId forKey:ClientUniqueIDConfigKey];

android/app/src/main/java/com/microsoft/codepush/react/CodePush.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -491,17 +491,15 @@ public void getNewStatusReport(Promise promise) {
491491
return;
492492
}
493493
}
494-
} else {
495-
if (isRunningBinaryVersion) {
496-
// Check if the current appVersion has been reported.
497-
String binaryIdentifier = "" + getBinaryResourcesModifiedTime();
498-
if (isDeploymentStatusNotYetReported(binaryIdentifier)) {
499-
recordDeploymentStatusReported(binaryIdentifier);
500-
WritableNativeMap reportMap = new WritableNativeMap();
501-
reportMap.putString("appVersion", appVersion);
502-
promise.resolve(reportMap);
503-
return;
504-
}
494+
} else if (isRunningBinaryVersion) {
495+
// Check if the current appVersion has been reported.
496+
String binaryIdentifier = "" + getBinaryResourcesModifiedTime();
497+
if (isDeploymentStatusNotYetReported(binaryIdentifier)) {
498+
recordDeploymentStatusReported(binaryIdentifier);
499+
WritableNativeMap reportMap = new WritableNativeMap();
500+
reportMap.putString("appVersion", appVersion);
501+
promise.resolve(reportMap);
502+
return;
505503
}
506504
}
507505

request-fetch-adapter.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
module.exports = {
2-
async request(verb, url, body, callback) {
3-
if (typeof body === "function") {
4-
callback = body;
5-
body = null;
2+
async request(verb, url, requestBody, callback) {
3+
if (typeof requestBody === "function") {
4+
callback = requestBody;
5+
requestBody = null;
66
}
77

88
var headers = {
99
"Accept": "application/json",
1010
"Content-Type": "application/json"
1111
};
1212

13-
if (body && typeof body === "object") {
14-
body = JSON.stringify(body);
13+
if (requestBody && typeof requestBody === "object") {
14+
requestBody = JSON.stringify(requestBody);
1515
}
1616

1717
try {
1818
const response = await fetch(url, {
1919
method: getHttpMethodName(verb),
2020
headers: headers,
21-
body: body
21+
body: requestBody
2222
});
2323

2424
const statusCode = response.status;

0 commit comments

Comments
 (0)