Skip to content

Commit

Permalink
Fix ON_NEXT_SUSPEND install mode (#1863)
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Krasavin committed May 29, 2020
1 parent df921ae commit ac97022
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions ios/CodePush/CodePush.m
Original file line number Diff line number Diff line change
Expand Up @@ -642,19 +642,25 @@ - (void)savePendingUpdate:(NSString *)packageHash
// a resume-based update still pending installation.
- (void)applicationWillEnterForeground
{
if (_appSuspendTimer) {
[_appSuspendTimer invalidate];
_appSuspendTimer = nil;
}
// Determine how long the app was in the background and ensure
// that it meets the minimum duration amount of time.
int durationInBackground = 0;
if (_lastResignedDate) {
durationInBackground = [[NSDate date] timeIntervalSinceDate:_lastResignedDate];
}

if (durationInBackground >= _minimumBackgroundDuration) {
[self loadBundle];
if (_installMode == CodePushInstallModeOnNextSuspend) {
// We shouldn't use loadBundle in this case, because _appSuspendTimer will call loadBundleOnTick.
// We should cancel timer for _appSuspendTimer because otherwise, we would call loadBundle two times.
if (durationInBackground < _minimumBackgroundDuration) {
[_appSuspendTimer invalidate];
_appSuspendTimer = nil;
}
} else {
// For resume install mode.
if (durationInBackground >= _minimumBackgroundDuration) {
[self loadBundle];
}
}
}

Expand Down

0 comments on commit ac97022

Please sign in to comment.