Add simulating an app store update being available

Will be automatically disabled when run from a build distributed by the App Store
This commit is contained in:
Andreas Linde 2013-04-01 01:39:51 +02:00 committed by Stephan Diederich
parent 166f2c7ccd
commit 7582f02a08
2 changed files with 42 additions and 1 deletions

View File

@ -159,7 +159,29 @@ typedef enum {
@property (nonatomic, assign, getter=isUpdateUIEnabled) BOOL updateUIEnabled;
// manually start an update check
///-----------------------------------------------------------------------------
/// @name Tests
///-----------------------------------------------------------------------------
/**
Define the simulated new version avaialble from the App Store
Set the version string that should be used for a simulated new version being available
in the App Store.
*Default*: _NIL_
@warning This property is autoamtically disabled if accidentally being invoked in an
App Store build.
@see updateSetting
*/
@property (nonatomic, strong) NSString *simulatedNewStoreVersion;
///-----------------------------------------------------------------------------
/// @name Manual update checking
///-----------------------------------------------------------------------------
/**
Check for an update

View File

@ -92,6 +92,7 @@
_appStoreURL = nil;
_currentUUID = [[self executableUUID] copy];
_countryCode = nil;
_simulatedNewStoreVersion = nil;
_mainBundle = [NSBundle mainBundle];
_currentLocale = [NSLocale currentLocale];
@ -237,6 +238,7 @@
#pragma mark - Private
- (BOOL)shouldCancelProcessing {
if (self.simulatedNewStoreVersion) return NO;
if (![self isAppStoreEnvironment]) return YES;
if (![self isStoreUpdateManagerEnabled]) return YES;
return NO;
@ -260,6 +262,13 @@
self.lastCheck = [NSDate date];
self.updateAvailable = [self hasNewVersion:json];
if (self.simulatedNewStoreVersion) {
self.updateAvailable = YES;
_lastCheckFailed = NO;
_newStoreVersion = self.simulatedNewStoreVersion;
}
BITHockeyLog(@"INFO: Update available: %i", self.updateAvailable);
if (_lastCheckFailed) {
@ -405,6 +414,14 @@
}
}
- (void)setSimulatedNewStoreVersion:(NSString *)aSimulatedNewStoreVersion {
if ([self isAppStoreEnvironment]) return;
if (_simulatedNewStoreVersion != aSimulatedNewStoreVersion) {
_simulatedNewStoreVersion = [aSimulatedNewStoreVersion copy];
}
}
#pragma mark - UIAlertViewDelegate
@ -424,6 +441,8 @@
if (_appStoreURL) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:_appStoreURL]];
} else {
BITHockeyLog(@"WARNING: The app store page couldn't be opened, since we did not get a valid URL from the store API.");
}
}
}