@@ -13,6 +13,8 @@ @implementation CodePush {
13
13
14
14
RCT_EXPORT_MODULE ()
15
15
16
+ #pragma mark - Private constants
17
+
16
18
static BOOL needToReportRollback = NO ;
17
19
static BOOL isRunningBinaryVersion = NO ;
18
20
static BOOL testConfigurationFlag = NO ;
@@ -38,9 +40,8 @@ @implementation CodePush {
38
40
static NSString *const PackageHashKey = @" packageHash" ;
39
41
static NSString *const PackageIsPendingKey = @" isPending" ;
40
42
41
- @synthesize bridge = _bridge;
43
+ # pragma mark - Public Obj-C API
42
44
43
- // Public Obj-C API (see header for method comments)
44
45
+ (NSURL *)bundleURL
45
46
{
46
47
return [self bundleURLForResource: @" main" ];
@@ -91,7 +92,7 @@ + (NSURL *)bundleURLForResource:(NSString *)resourceName
91
92
#ifndef DEBUG
92
93
[CodePush clearUpdates ];
93
94
#endif
94
-
95
+
95
96
NSLog (logMessageFormat, binaryJsBundleUrl);
96
97
isRunningBinaryVersion = YES ;
97
98
return binaryJsBundleUrl;
@@ -113,7 +114,12 @@ + (BOOL)isUsingTestConfiguration
113
114
return testConfigurationFlag;
114
115
}
115
116
116
- /*
117
+ + (void )setDeploymentKey : (NSString *)deploymentKey
118
+ {
119
+ [CodePushConfig current ].deploymentKey = deploymentKey;
120
+ }
121
+
122
+ /*
117
123
* This is used to enable an environment in which tests can be run.
118
124
* Specifically, it flips a boolean flag that causes bundles to be
119
125
* saved to a test folder and enables the ability to modify
@@ -134,8 +140,9 @@ + (void)clearUpdates
134
140
[self removeFailedUpdates ];
135
141
}
136
142
143
+ #pragma mark - Private API methods
137
144
138
- // Private API methods
145
+ @synthesize bridge = _bridge;
139
146
140
147
/*
141
148
* This method is used by the React Native bridge to allow
@@ -147,10 +154,10 @@ - (NSDictionary *)constantsToExport
147
154
{
148
155
// Export the values of the CodePushInstallMode enum
149
156
// so that the script-side can easily stay in sync
150
- return @{
151
- @" codePushInstallModeOnNextRestart" :@(CodePushInstallModeOnNextRestart),
152
- @" codePushInstallModeImmediate" : @(CodePushInstallModeImmediate),
153
- @" codePushInstallModeOnNextResume" : @(CodePushInstallModeOnNextResume)
157
+ return @{
158
+ @" codePushInstallModeOnNextRestart" :@(CodePushInstallModeOnNextRestart),
159
+ @" codePushInstallModeImmediate" : @(CodePushInstallModeImmediate),
160
+ @" codePushInstallModeOnNextResume" : @(CodePushInstallModeOnNextResume)
154
161
};
155
162
};
156
163
@@ -257,7 +264,7 @@ - (BOOL)isPendingUpdate:(NSString*)packageHash
257
264
{
258
265
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults ];
259
266
NSDictionary *pendingUpdate = [preferences objectForKey: PendingUpdateKey];
260
-
267
+
261
268
// If there is a pending update whose "state" isn't loading, then we consider it "pending".
262
269
// Additionally, if a specific hash was provided, we ensure it matches that of the pending update.
263
270
BOOL updateIsPending = pendingUpdate &&
@@ -380,7 +387,7 @@ - (void)savePendingUpdate:(NSString *)packageHash
380
387
[preferences synchronize ];
381
388
}
382
389
383
- // JavaScript-exported module methods
390
+ # pragma mark - JavaScript-exported module methods
384
391
385
392
/*
386
393
* This is native-side of the RemotePackage.download method
@@ -404,11 +411,11 @@ - (void)savePendingUpdate:(NSString *)packageHash
404
411
doneCallback: ^{
405
412
NSError *err;
406
413
NSDictionary *newPackage = [CodePushPackage getPackage: updatePackage[PackageHashKey] error: &err];
407
-
414
+
408
415
if (err) {
409
416
return reject (err);
410
417
}
411
-
418
+
412
419
resolve (newPackage);
413
420
}
414
421
// The download failed
@@ -447,7 +454,7 @@ - (void)savePendingUpdate:(NSString *)packageHash
447
454
// the script-side doesn't need to immediately call back into native to populate it.
448
455
BOOL isPendingUpdate = [self isPendingUpdate: [package objectForKey: PackageHashKey]];
449
456
[package setObject: @(isPendingUpdate) forKey: PackageIsPendingKey];
450
-
457
+
451
458
resolve (package);
452
459
});
453
460
}
@@ -527,7 +534,7 @@ - (void)savePendingUpdate:(NSString *)packageHash
527
534
}
528
535
529
536
/*
530
- * This method is checks if a new status update exists (new version was installed,
537
+ * This method is checks if a new status update exists (new version was installed,
531
538
* or an update failed) and return its details (version label, status).
532
539
*/
533
540
RCT_EXPORT_METHOD (getNewStatusReport:(RCTPromiseResolveBlock)resolve
@@ -589,7 +596,7 @@ - (void)savePendingUpdate:(NSString *)packageHash
589
596
/*
590
597
* This method is the native side of the CodePush.downloadAndReplaceCurrentBundle()
591
598
* method, which replaces the current bundle with the one downloaded from
592
- * removeBundleUrl. It is only to be used during tests and no-ops if the test
599
+ * removeBundleUrl. It is only to be used during tests and no-ops if the test
593
600
* configuration flag is not set.
594
601
*/
595
602
RCT_EXPORT_METHOD (downloadAndReplaceCurrentBundle:(NSString *)remoteBundleUrl)
@@ -599,4 +606,4 @@ - (void)savePendingUpdate:(NSString *)packageHash
599
606
}
600
607
}
601
608
602
- @end
609
+ @end
0 commit comments