This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,10 @@ function log(message) {
109
109
console . log ( `[CodePush] ${ message } ` )
110
110
}
111
111
112
+ function restartApp ( onlyIfUpdateIsPending = false ) {
113
+ NativeCodePush . restartApp ( onlyIfUpdateIsPending ) ;
114
+ }
115
+
112
116
var testConfig ;
113
117
114
118
// This function is only used for tests. Replaces the default SDK, configuration and native bridge
@@ -265,7 +269,7 @@ const CodePush = {
265
269
getCurrentPackage,
266
270
log,
267
271
notifyApplicationReady : NativeCodePush . notifyApplicationReady ,
268
- restartApp : NativeCodePush . restartApp ,
272
+ restartApp,
269
273
setUpTestDependencies,
270
274
sync,
271
275
InstallMode : {
Original file line number Diff line number Diff line change @@ -203,11 +203,11 @@ - (BOOL)isPendingUpdate:(NSString*)packageHash
203
203
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults ];
204
204
NSDictionary *pendingUpdate = [preferences objectForKey: PendingUpdateKey];
205
205
206
- // If there is a pending update, whose hash is equal to the one
207
- // specified, and its "state" isn't loading, then we consider it " pending" .
206
+ // If there is a pending update whose "state" isn't loading, then we consider it "pending".
207
+ // Additionally, if a specific hash was provided, we ensure it matches that of the pending update .
208
208
BOOL updateIsPending = pendingUpdate &&
209
209
[pendingUpdate[PendingUpdateIsLoadingKey] boolValue ] == NO &&
210
- [pendingUpdate[PendingUpdateHashKey] isEqualToString: packageHash];
210
+ (!packageHash || [pendingUpdate[PendingUpdateHashKey] isEqualToString: packageHash]) ;
211
211
212
212
return updateIsPending;
213
213
}
@@ -467,9 +467,13 @@ - (void)savePendingUpdate:(NSString *)packageHash
467
467
/*
468
468
* This method is the native side of the CodePush.restartApp() method.
469
469
*/
470
- RCT_EXPORT_METHOD (restartApp)
470
+ RCT_EXPORT_METHOD (restartApp:( BOOL )onlyIfUpdateIsPending )
471
471
{
472
- [self loadBundle ];
472
+ // If this is an unconditional restart request, or there
473
+ // is current pending update, then reload the app.
474
+ if (!onlyIfUpdateIsPending || [self isPendingUpdate: nil ]) {
475
+ [self loadBundle ];
476
+ }
473
477
}
474
478
475
479
/*
You can’t perform that action at this time.
0 commit comments