Skip to content

Commit ac97022

Browse files
author
Igor Krasavin
authored
Fix ON_NEXT_SUSPEND install mode (#1863)
1 parent df921ae commit ac97022

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

ios/CodePush/CodePush.m

+12-6
Original file line numberDiff line numberDiff line change
@@ -642,19 +642,25 @@ - (void)savePendingUpdate:(NSString *)packageHash
642642
// a resume-based update still pending installation.
643643
- (void)applicationWillEnterForeground
644644
{
645-
if (_appSuspendTimer) {
646-
[_appSuspendTimer invalidate];
647-
_appSuspendTimer = nil;
648-
}
649645
// Determine how long the app was in the background and ensure
650646
// that it meets the minimum duration amount of time.
651647
int durationInBackground = 0;
652648
if (_lastResignedDate) {
653649
durationInBackground = [[NSDate date] timeIntervalSinceDate:_lastResignedDate];
654650
}
655651

656-
if (durationInBackground >= _minimumBackgroundDuration) {
657-
[self loadBundle];
652+
if (_installMode == CodePushInstallModeOnNextSuspend) {
653+
// We shouldn't use loadBundle in this case, because _appSuspendTimer will call loadBundleOnTick.
654+
// We should cancel timer for _appSuspendTimer because otherwise, we would call loadBundle two times.
655+
if (durationInBackground < _minimumBackgroundDuration) {
656+
[_appSuspendTimer invalidate];
657+
_appSuspendTimer = nil;
658+
}
659+
} else {
660+
// For resume install mode.
661+
if (durationInBackground >= _minimumBackgroundDuration) {
662+
[self loadBundle];
663+
}
658664
}
659665
}
660666

0 commit comments

Comments
 (0)