@@ -16,6 +16,12 @@ @implementation CodePush
16
16
NSString * const FailedUpdatesKey = @" CODE_PUSH_FAILED_UPDATES" ;
17
17
NSString * const PendingUpdateKey = @" CODE_PUSH_PENDING_UPDATE" ;
18
18
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
+
19
25
@synthesize bridge = _bridge;
20
26
21
27
// Public Obj-C API
@@ -65,7 +71,7 @@ - (void)checkForPendingUpdate:(BOOL)isAppStart {
65
71
if (pendingUpdate)
66
72
{
67
73
NSError *error;
68
- NSString *pendingHash = pendingUpdate[@" hash " ];
74
+ NSString *pendingHash = pendingUpdate[PendingUpdateHashKey ];
69
75
NSString *currentHash = [CodePushPackage getCurrentPackageHash: &error];
70
76
71
77
// If the current hash is equivalent to the pending hash, then the app
@@ -75,9 +81,9 @@ - (void)checkForPendingUpdate:(BOOL)isAppStart {
75
81
// We only want to initialize the rollback timer in two scenarios:
76
82
// 1) The app has been restarted, and therefore, the pending update is already applied
77
83
// 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 ]))
79
85
{
80
- int rollbackTimeout = [pendingUpdate[@" rollbackTimeout " ] intValue ];
86
+ int rollbackTimeout = [pendingUpdate[PendingUpdateRollbackTimeoutKey ] intValue ];
81
87
82
88
// If the app wasn't restarted "naturally", then we need to restart it manually
83
89
BOOL needsRestart = !isAppStart;
@@ -197,9 +203,9 @@ - (void)savePendingUpdate:(NSString *)packageHash
197
203
// was applied, but hasn't yet become "active".
198
204
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults ];
199
205
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 ,
203
209
nil ];
204
210
205
211
[preferences setObject: pendingUpdate forKey: PendingUpdateKey];
0 commit comments