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

Commit 8cd36cd

Browse files
committed
Converting pending update keys to consts
1 parent 18469b5 commit 8cd36cd

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

CodePush.m

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ @implementation CodePush
1616
NSString * const FailedUpdatesKey = @"CODE_PUSH_FAILED_UPDATES";
1717
NSString * const PendingUpdateKey = @"CODE_PUSH_PENDING_UPDATE";
1818

19+
// These keys are already "namespaced" by the PendingUpdateKey, so
20+
// their values don't need to be obfuscated to prevent collision with app data
21+
NSString * const PendingUpdateAllowsRestartOnResumeKey = @"allowsRestartOnResume";
22+
NSString * const PendingUpdateHashKey = @"hash";
23+
NSString * const PendingUpdateRollbackTimeoutKey = @"rollbackTimeout";
24+
1925
@synthesize bridge = _bridge;
2026

2127
// Public Obj-C API
@@ -65,7 +71,7 @@ - (void)checkForPendingUpdate:(BOOL)isAppStart {
6571
if (pendingUpdate)
6672
{
6773
NSError *error;
68-
NSString *pendingHash = pendingUpdate[@"hash"];
74+
NSString *pendingHash = pendingUpdate[PendingUpdateHashKey];
6975
NSString *currentHash = [CodePushPackage getCurrentPackageHash:&error];
7076

7177
// If the current hash is equivalent to the pending hash, then the app
@@ -75,9 +81,9 @@ - (void)checkForPendingUpdate:(BOOL)isAppStart {
7581
// We only want to initialize the rollback timer in two scenarios:
7682
// 1) The app has been restarted, and therefore, the pending update is already applied
7783
// 2) The app has been resumed, and the pending update indicates it supports being restarted on resume
78-
if (isAppStart || (!isAppStart && [pendingUpdate[@"allowRestartOnResume"] boolValue]))
84+
if (isAppStart || (!isAppStart && [pendingUpdate[PendingUpdateAllowsRestartOnResumeKey] boolValue]))
7985
{
80-
int rollbackTimeout = [pendingUpdate[@"rollbackTimeout"] intValue];
86+
int rollbackTimeout = [pendingUpdate[PendingUpdateRollbackTimeoutKey] intValue];
8187

8288
// If the app wasn't restarted "naturally", then we need to restart it manually
8389
BOOL needsRestart = !isAppStart;
@@ -197,9 +203,9 @@ - (void)savePendingUpdate:(NSString *)packageHash
197203
// was applied, but hasn't yet become "active".
198204
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
199205
NSDictionary *pendingUpdate = [[NSDictionary alloc] initWithObjectsAndKeys:
200-
packageHash,@"hash",
201-
[NSNumber numberWithInt:rollbackTimeout],@"rollbackTimeout",
202-
[NSNumber numberWithBool:allowRestartOnResume],@"allowRestartOnResume",
206+
packageHash,PendingUpdateHashKey,
207+
[NSNumber numberWithInt:rollbackTimeout],PendingUpdateRollbackTimeoutKey,
208+
[NSNumber numberWithBool:allowRestartOnResume],PendingUpdateAllowsRestartOnResumeKey,
203209
nil];
204210

205211
[preferences setObject:pendingUpdate forKey:PendingUpdateKey];

0 commit comments

Comments
 (0)