Enable JSON for App Store builds, but do not submit the UDID and don't evaluate the returned JSON.

This commit is contained in:
Thomas Dohmke 2011-12-05 15:41:20 +01:00
parent 9162b740e9
commit ec5178919f
2 changed files with 104 additions and 112 deletions

View File

@ -423,8 +423,6 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
NSLog(@"WARNING: Hockey.bundle is missing, make sure it is added!");
}
if (!isAppStoreEnvironment_) {
[self loadAppCache_];
[self startUsage];
@ -439,12 +437,10 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
name:UIApplicationWillTerminateNotification
object:nil];
}
}
return self;
}
- (void)dealloc {
if (!isAppStoreEnvironment_) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:BWHockeyNetworkBecomeReachable object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillTerminateNotification object:nil];
@ -452,7 +448,6 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil];
)
}
self.delegate = nil;
[urlConnection_ cancel];
@ -540,6 +535,8 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
- (void)showCheckForUpdateAlert_ {
if (isAppStoreEnvironment_) return;
if (!updateAlertShowing_) {
if ([self.app.mandatory boolValue] ) {
UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:BWHockeyLocalize(@"HockeyUpdateAvailable")
@ -704,19 +701,19 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
#pragma mark RequestComments
- (BOOL)shouldCheckForUpdates {
if (isAppStoreEnvironment_) return NO;
BOOL checkForUpdate = NO;
switch (self.updateSetting) {
case HockeyUpdateCheckStartup:
checkForUpdate = YES;
break;
case HockeyUpdateCheckDaily:
case HockeyUpdateCheckDaily: {
NSTimeInterval dateDiff = fabs([self.lastCheck timeIntervalSinceNow]);
if (dateDiff != 0)
dateDiff = dateDiff / (60*60*24);
checkForUpdate = (dateDiff >= 1);
break;
}
case HockeyUpdateCheckManually:
checkForUpdate = NO;
break;
@ -731,7 +728,7 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
[parameter appendFormat:@"?format=json&authorize=yes&app_version=%@&udid=%@",
[[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"] bw_URLEncodedString],
[[self deviceIdentifier] bw_URLEncodedString]
([self isAppStoreEnvironment] ? @"appstore" : [[self deviceIdentifier] bw_URLEncodedString])
];
// build request & send
@ -798,7 +795,6 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
}
- (void)checkForUpdate {
if (isAppStoreEnvironment_) return;
if (self.requireAuthorization) return;
if (self.isUpdateAvailable && [self.app.mandatory boolValue]) {
[self showCheckForUpdateAlert_];
@ -808,7 +804,6 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
}
- (void)checkForUpdateShowFeedback:(BOOL)feedback {
if (isAppStoreEnvironment_) return;
if (self.isCheckInProgress) return;
showFeedback_ = feedback;
@ -823,7 +818,7 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
NSMutableString *parameter = [NSMutableString stringWithFormat:@"api/2/apps/%@?format=json&udid=%@",
[[self encodedAppIdentifier_] bw_URLEncodedString],
[[self deviceIdentifier] bw_URLEncodedString]];
([self isAppStoreEnvironment] ? @"" : [[self deviceIdentifier] bw_URLEncodedString])];
// add additional statistics if user didn't disable flag
if ([self canSendUserData]) {
@ -863,6 +858,8 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
}
- (BOOL)initiateAppDownload {
if ([self isAppStoreEnvironment]) return NO;
if (!self.isUpdateAvailable) {
BWHockeyLog(@"Warning: No update available. Aborting.");
return NO;
@ -925,8 +922,6 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
// begin the startup process
- (void)startManager {
if (isAppStoreEnvironment_) return;
if (![self appVersionIsAuthorized]) {
if ([self authorizationState] == HockeyAuthorizationPending) {
[self showAuthorizationScreen:BWHockeyLocalize(@"HockeyAuthorizationProgress") image:@"authorize_request.png"];
@ -993,9 +988,11 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
BWHockeyLog(@"Received API response: %@", responseString);
id json = [self parseJSONResultString:responseString];
NSArray *feedArray = (NSArray *)([self checkForTracker] ? [json valueForKey:@"versions"] : json);
self.trackerConfig = ([self checkForTracker] ? [json valueForKey:@"tracker"] : nil);
if (![self isAppStoreEnvironment]) {
NSArray *feedArray = (NSArray *)([self checkForTracker] ? [json valueForKey:@"versions"] : json);
self.receivedData = nil;
self.urlConnection = nil;
@ -1054,7 +1051,8 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
}
}
showFeedback_ = NO;
}else {
}
} else {
[self reportError_:[NSError errorWithDomain:kHockeyErrorDomain code:HockeyAPIServerReturnedEmptyResponse userInfo:
[NSDictionary dictionaryWithObjectsAndKeys:@"Server returned an empty response.", NSLocalizedDescriptionKey, nil]]];
}
@ -1080,7 +1078,6 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
}
BW_IF_IOS4_OR_GREATER(
if (!isAppStoreEnvironment_) {
// register/deregister logic
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
if (!updateURL_ && anUpdateURL) {
@ -1090,7 +1087,6 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
[dnc removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
[dnc removeObserver:self name:UIApplicationWillResignActiveNotification object:nil];
}
}
)
if (updateURL_ != anUpdateURL) {
@ -1098,9 +1094,7 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
updateURL_ = [anUpdateURL copy];
}
if (!isAppStoreEnvironment_) {
[self performSelector:@selector(startManager) withObject:nil afterDelay:0.0f];
}
}
- (void)setAppIdentifier:(NSString *)anAppIdentifier {
@ -1116,14 +1110,12 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
if (checkForUpdateOnLaunch_ != flag) {
checkForUpdateOnLaunch_ = flag;
BW_IF_IOS4_OR_GREATER(
if (!isAppStoreEnvironment_) {
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
if (flag) {
[dnc addObserver:self selector:@selector(checkForUpdate) name:UIApplicationDidBecomeActiveNotification object:nil];
} else {
[dnc removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
}
}
)
}
}

View File

@ -136,12 +136,12 @@
if ([self shouldUseLiveIdenfitier]) {
appIdentifier = [liveIdentifier copy];
[self configureQuincyManager];
}
else {
appIdentifier = [betaIdentifier copy];
}
if (appIdentifier) {
[self configureQuincyManager];
[self configureHockeyManager];
}