Add support for background fetch in BITUpdateManager

Checks for updates will only be done if the app is in the foreground. This is just for double safety, since the BITAuthenticator already reports that the app is not validated in this case
This commit is contained in:
Andreas Linde
2013-09-16 13:53:07 +02:00
parent 3132b6d83b
commit 9e0db07308

View File

@@ -88,14 +88,14 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
- (void)didBecomeActiveActions {
if (![self isUpdateManagerDisabled]) {
[self checkExpiryDateReached];
if (![self expiryDateReached]) {
[self startUsage];
if (_checkForUpdateOnLaunch) {
[self checkForUpdate];
}
}
if ([self isUpdateManagerDisabled]) return;
[self checkExpiryDateReached];
if ([self expiryDateReached]) return;
[self startUsage];
if (_checkForUpdateOnLaunch) {
[self checkForUpdate];
}
}
@@ -639,12 +639,14 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
- (void)startManager {
if (![self isAppStoreEnvironment]) {
if ([self isUpdateManagerDisabled]) return;
BITHockeyLog(@"INFO: Starting UpdateManager");
[self checkExpiryDateReached];
if (![self expiryDateReached]) {
if ([self checkForTracker] || ([self isCheckForUpdateOnLaunch] && [self shouldCheckForUpdates])) {
if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateActive) return;
[self performSelector:@selector(checkForUpdate) withObject:nil afterDelay:1.0f];
}
}
@@ -652,6 +654,8 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
if ([self checkForTracker]) {
// if we are in the app store, make sure not to send usage information in any case for now
_sendUsageData = NO;
if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateActive) return;
[self performSelector:@selector(checkForUpdate) withObject:nil afterDelay:1.0f];
}