@@ -13,6 +13,8 @@ @implementation CodePush {
1313
1414RCT_EXPORT_MODULE ()
1515
16+ #pragma mark - Private constants
17+
1618static BOOL needToReportRollback = NO ;
1719static BOOL isRunningBinaryVersion = NO ;
1820static BOOL testConfigurationFlag = NO ;
@@ -38,9 +40,8 @@ @implementation CodePush {
3840static NSString *const PackageHashKey = @" packageHash" ;
3941static NSString *const PackageIsPendingKey = @" isPending" ;
4042
41- @synthesize bridge = _bridge;
43+ # pragma mark - Public Obj-C API
4244
43- // Public Obj-C API (see header for method comments)
4445+ (NSURL *)bundleURL
4546{
4647 return [self bundleURLForResource: @" main" ];
@@ -91,7 +92,7 @@ + (NSURL *)bundleURLForResource:(NSString *)resourceName
9192#ifndef DEBUG
9293 [CodePush clearUpdates ];
9394#endif
94-
95+
9596 NSLog (logMessageFormat, binaryJsBundleUrl);
9697 isRunningBinaryVersion = YES ;
9798 return binaryJsBundleUrl;
@@ -113,7 +114,12 @@ + (BOOL)isUsingTestConfiguration
113114 return testConfigurationFlag;
114115}
115116
116- /*
117+ + (void )setDeploymentKey : (NSString *)deploymentKey
118+ {
119+ [CodePushConfig current ].deploymentKey = deploymentKey;
120+ }
121+
122+ /*
117123 * This is used to enable an environment in which tests can be run.
118124 * Specifically, it flips a boolean flag that causes bundles to be
119125 * saved to a test folder and enables the ability to modify
@@ -134,8 +140,9 @@ + (void)clearUpdates
134140 [self removeFailedUpdates ];
135141}
136142
143+ #pragma mark - Private API methods
137144
138- // Private API methods
145+ @synthesize bridge = _bridge;
139146
140147/*
141148 * This method is used by the React Native bridge to allow
@@ -147,10 +154,10 @@ - (NSDictionary *)constantsToExport
147154{
148155 // Export the values of the CodePushInstallMode enum
149156 // 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)
154161 };
155162};
156163
@@ -257,7 +264,7 @@ - (BOOL)isPendingUpdate:(NSString*)packageHash
257264{
258265 NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults ];
259266 NSDictionary *pendingUpdate = [preferences objectForKey: PendingUpdateKey];
260-
267+
261268 // If there is a pending update whose "state" isn't loading, then we consider it "pending".
262269 // Additionally, if a specific hash was provided, we ensure it matches that of the pending update.
263270 BOOL updateIsPending = pendingUpdate &&
@@ -380,7 +387,7 @@ - (void)savePendingUpdate:(NSString *)packageHash
380387 [preferences synchronize ];
381388}
382389
383- // JavaScript-exported module methods
390+ # pragma mark - JavaScript-exported module methods
384391
385392/*
386393 * This is native-side of the RemotePackage.download method
@@ -404,11 +411,11 @@ - (void)savePendingUpdate:(NSString *)packageHash
404411 doneCallback: ^{
405412 NSError *err;
406413 NSDictionary *newPackage = [CodePushPackage getPackage: updatePackage[PackageHashKey] error: &err];
407-
414+
408415 if (err) {
409416 return reject (err);
410417 }
411-
418+
412419 resolve (newPackage);
413420 }
414421 // The download failed
@@ -447,7 +454,7 @@ - (void)savePendingUpdate:(NSString *)packageHash
447454 // the script-side doesn't need to immediately call back into native to populate it.
448455 BOOL isPendingUpdate = [self isPendingUpdate: [package objectForKey: PackageHashKey]];
449456 [package setObject: @(isPendingUpdate) forKey: PackageIsPendingKey];
450-
457+
451458 resolve (package);
452459 });
453460}
@@ -527,7 +534,7 @@ - (void)savePendingUpdate:(NSString *)packageHash
527534}
528535
529536/*
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,
531538 * or an update failed) and return its details (version label, status).
532539 */
533540RCT_EXPORT_METHOD (getNewStatusReport:(RCTPromiseResolveBlock)resolve
@@ -589,7 +596,7 @@ - (void)savePendingUpdate:(NSString *)packageHash
589596/*
590597 * This method is the native side of the CodePush.downloadAndReplaceCurrentBundle()
591598 * 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
593600 * configuration flag is not set.
594601 */
595602RCT_EXPORT_METHOD (downloadAndReplaceCurrentBundle:(NSString *)remoteBundleUrl)
@@ -599,4 +606,4 @@ - (void)savePendingUpdate:(NSString *)packageHash
599606 }
600607}
601608
602- @end
609+ @end
0 commit comments