From 9e0db073082e91ef2341a030de653c835acf7be0 Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Mon, 16 Sep 2013 13:53:07 +0200 Subject: [PATCH] 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 --- Classes/BITUpdateManager.m | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Classes/BITUpdateManager.m b/Classes/BITUpdateManager.m index 9aebe429c9..41a7e0cd74 100644 --- a/Classes/BITUpdateManager.m +++ b/Classes/BITUpdateManager.m @@ -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]; }