Merge branch 'release/2.2.4'

* release/2.2.4:
  Updated Hockey.bundle.
  Make sure if the installed version is newer, mandatory is ignored
  Add SDK info to update request too
  Increase podspec version number
  Add SDK version number to source and send it to the server, together with the SDK name
  Improve handling of mandatory flag
  Don't crash if no JSON serializer is found, show an error in the log instead
  Updated podspec.
  don't add a target selector for removed method
  removed PSLog to prevent conflicts with other SDKs
  Fix for using any method automatically triggering checkForUpdate via notification
  Fix potential crash if json string is nil

Conflicts:
	HockeySDK.podspec
This commit is contained in:
Andreas Linde 2012-03-12 16:15:52 +01:00
commit 5f407647e0
9 changed files with 58 additions and 29 deletions

View File

@ -229,6 +229,9 @@ typedef enum {
- (NSArray *)apps; - (NSArray *)apps;
// check if there is any newer version mandatory
- (BOOL)hasNewerMandatoryVersion;
@end @end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -40,6 +40,9 @@
#define BETA_UPDATE_TIMESTAMP @"timestamp" #define BETA_UPDATE_TIMESTAMP @"timestamp"
#define BETA_UPDATE_APPSIZE @"appsize" #define BETA_UPDATE_APPSIZE @"appsize"
#define SDK_NAME @"HockeySDK"
#define SDK_VERSION @"2.2.4"
@interface BWHockeyManager () @interface BWHockeyManager ()
- (NSString *)getDevicePlatform_; - (NSString *)getDevicePlatform_;
- (id)parseJSONResultString:(NSString *)jsonString; - (id)parseJSONResultString:(NSString *)jsonString;
@ -539,7 +542,7 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
if (isAppStoreEnvironment_) return; if (isAppStoreEnvironment_) return;
if (!updateAlertShowing_) { if (!updateAlertShowing_) {
if ([self.app.mandatory boolValue] ) { if ([self hasNewerMandatoryVersion]) {
UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:BWHockeyLocalize(@"HockeyUpdateAvailable") UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:BWHockeyLocalize(@"HockeyUpdateAvailable")
message:[NSString stringWithFormat:BWHockeyLocalize(@"HockeyUpdateAlertMandatoryTextWithAppVersion"), [self.app nameAndVersionString]] message:[NSString stringWithFormat:BWHockeyLocalize(@"HockeyUpdateAlertMandatoryTextWithAppVersion"), [self.app nameAndVersionString]]
delegate:self delegate:self
@ -634,6 +637,9 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
NSError *error = nil; NSError *error = nil;
id feedResult = nil; id feedResult = nil;
if (!jsonString)
return nil;
#if BW_NATIVE_JSON_AVAILABLE #if BW_NATIVE_JSON_AVAILABLE
feedResult = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error]; feedResult = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error];
#else #else
@ -648,6 +654,10 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
invocation.target = nsjsonClass; invocation.target = nsjsonClass;
invocation.selector = nsjsonSelect; invocation.selector = nsjsonSelect;
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
if (!jsonData)
return nil;
[invocation setArgument:&jsonData atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation [invocation setArgument:&jsonData atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
NSUInteger readOptions = kNilOptions; NSUInteger readOptions = kNilOptions;
[invocation setArgument:&readOptions atIndex:3]; [invocation setArgument:&readOptions atIndex:3];
@ -683,13 +693,13 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
[invocation invoke]; [invocation invoke];
[invocation getReturnValue:&feedResult]; [invocation getReturnValue:&feedResult];
} else { } else {
NSLog(@"Error: You need a JSON Framework in your runtime!"); error = [NSError errorWithDomain:kHockeyErrorDomain
[self doesNotRecognizeSelector:_cmd]; code:HockeyAPIServerReturnedEmptyResponse
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"You need a JSON Framework in your runtime for iOS4!", NSLocalizedDescriptionKey, nil]];
} }
#endif #endif
if (error) { if (error) {
BWHockeyLog(@"Error while parsing response feed: %@", [error localizedDescription]);
[self reportError_:error]; [self reportError_:error];
return nil; return nil;
} }
@ -727,9 +737,11 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
- (void)checkForAuthorization { - (void)checkForAuthorization {
NSMutableString *parameter = [NSMutableString stringWithFormat:@"api/2/apps/%@", [self encodedAppIdentifier_]]; NSMutableString *parameter = [NSMutableString stringWithFormat:@"api/2/apps/%@", [self encodedAppIdentifier_]];
[parameter appendFormat:@"?format=json&authorize=yes&app_version=%@&udid=%@", [parameter appendFormat:@"?format=json&authorize=yes&app_version=%@&udid=%@&sdk=%@&sdk_version=%@",
[[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"] bw_URLEncodedString], [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"] bw_URLEncodedString],
([self isAppStoreEnvironment] ? @"appstore" : [[self deviceIdentifier] bw_URLEncodedString]) ([self isAppStoreEnvironment] ? @"appstore" : [[self deviceIdentifier] bw_URLEncodedString]),
SDK_NAME,
SDK_VERSION
]; ];
// build request & send // build request & send
@ -796,10 +808,10 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
} }
- (void)checkForUpdate { - (void)checkForUpdate {
if (!updateURL_) return;
if (self.requireAuthorization) return; if (self.requireAuthorization) return;
if (self.isUpdateAvailable && [self.app.mandatory boolValue]) { if (self.isUpdateAvailable && [self hasNewerMandatoryVersion]) {
[self showCheckForUpdateAlert_]; [self showCheckForUpdateAlert_];
return;
} }
[self checkForUpdateShowFeedback:NO]; [self checkForUpdateShowFeedback:NO];
} }
@ -817,9 +829,11 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
return; return;
} }
NSMutableString *parameter = [NSMutableString stringWithFormat:@"api/2/apps/%@?format=json&udid=%@", NSMutableString *parameter = [NSMutableString stringWithFormat:@"api/2/apps/%@?format=json&udid=%@&sdk=%@&sdk_version=%@",
[[self encodedAppIdentifier_] bw_URLEncodedString], [[self encodedAppIdentifier_] bw_URLEncodedString],
([self isAppStoreEnvironment] ? @"appstore" : [[self deviceIdentifier] bw_URLEncodedString])]; ([self isAppStoreEnvironment] ? @"appstore" : [[self deviceIdentifier] bw_URLEncodedString]),
SDK_NAME,
SDK_VERSION];
// add additional statistics if user didn't disable flag // add additional statistics if user didn't disable flag
if ([self canSendUserData]) { if ([self canSendUserData]) {
@ -1046,7 +1060,7 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
[alert release]; [alert release];
} }
if (self.isUpdateAvailable && (self.alwaysShowUpdateReminder || newVersionDiffersFromCachedVersion || [self.app.mandatory boolValue])) { if (self.isUpdateAvailable && (self.alwaysShowUpdateReminder || newVersionDiffersFromCachedVersion || [self hasNewerMandatoryVersion])) {
if (updateAvailable_ && !currentHockeyViewController_) { if (updateAvailable_ && !currentHockeyViewController_) {
[self showCheckForUpdateAlert_]; [self showCheckForUpdateAlert_];
} }
@ -1059,6 +1073,21 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
} }
} }
- (BOOL)hasNewerMandatoryVersion {
BOOL result = NO;
for (BWApp *app in self.apps) {
if ([app.version isEqualToString:self.currentAppVersion] || [app.version versionCompare:self.currentAppVersion] == NSOrderedAscending) {
break;
}
if ([app.mandatory boolValue]) {
result = YES;
}
}
return result;
}
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - #pragma mark -

View File

@ -35,6 +35,9 @@
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <inttypes.h> //needed for PRIx64 macro #include <inttypes.h> //needed for PRIx64 macro
#define SDK_NAME @"HockeySDK"
#define SDK_VERSION @"2.2.4"
NSBundle *quincyBundle(void) { NSBundle *quincyBundle(void) {
static NSBundle* bundle = nil; static NSBundle* bundle = nil;
if (!bundle) { if (!bundle) {
@ -606,11 +609,13 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
if (self.appIdentifier) { if (self.appIdentifier) {
request = [NSMutableURLRequest requestWithURL: request = [NSMutableURLRequest requestWithURL:
[NSURL URLWithString:[NSString stringWithFormat:@"%@api/2/apps/%@/crashes", [NSURL URLWithString:[NSString stringWithFormat:@"%@api/2/apps/%@/crashes?sdk=%@&sdk_version=%@",
self.submissionURL, self.submissionURL,
[self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] [self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
] SDK_NAME,
]]; SDK_VERSION
]
]];
} else { } else {
request = [NSMutableURLRequest requestWithURL:url]; request = [NSMutableURLRequest requestWithURL:url];
} }

View File

@ -27,12 +27,6 @@
#import "PSStoreButton.h" #import "PSStoreButton.h"
#ifdef DEBUG
#define PSLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define PSLog(...)
#endif
#define PS_RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1] #define PS_RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]
#define PS_MIN_HEIGHT 25.0f #define PS_MIN_HEIGHT 25.0f
#define PS_MAX_WIDTH 120.0f #define PS_MAX_WIDTH 120.0f
@ -87,12 +81,7 @@
#pragma mark - #pragma mark -
#pragma mark private #pragma mark private
- (void)touchedUpOutside:(id)sender {
PSLog(@"touched outside...");
}
- (void)buttonPressed:(id)sender { - (void)buttonPressed:(id)sender {
PSLog(@"calling delegate:storeButtonFired for %@", sender);
[buttonDelegate_ storeButtonFired:self]; [buttonDelegate_ storeButtonFired:self];
} }
@ -182,7 +171,6 @@
[self.titleLabel setFont:[UIFont boldSystemFontOfSize:13.0]]; [self.titleLabel setFont:[UIFont boldSystemFontOfSize:13.0]];
// register for touch events // register for touch events
[self addTarget:self action:@selector(touchedUpOutside:) forControlEvents:UIControlEventTouchUpOutside];
[self addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; [self addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
// border layers for more sex! // border layers for more sex!

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'HockeySDK' s.name = 'HockeySDK'
s.version = '2.2.3' s.version = '2.2.4'
s.license = 'MIT' s.license = 'MIT'
s.platform = :ios s.platform = :ios
s.summary = 'Distribute beta apps and collect crash reports with HockeyApp.' s.summary = 'Distribute beta apps and collect crash reports with HockeyApp.'

View File

@ -63,6 +63,7 @@
"HockeyNoUpdateNeededTitle" = "Kein Update Verfügbar"; "HockeyNoUpdateNeededTitle" = "Kein Update Verfügbar";
"HockeyNoUpdateNeededMessage" = "%@ ist bereits die aktuellste Version."; "HockeyNoUpdateNeededMessage" = "%@ ist bereits die aktuellste Version.";
"HockeyUpdateAlertTextWithAppVersion" = "%@ ist verfügbar."; "HockeyUpdateAlertTextWithAppVersion" = "%@ ist verfügbar.";
"HockeyUpdateAlertMandatoryTextWithAppVersion" = "%@ ist verfügbar und muss installiert werden!";
"HockeyIgnore" = "Ignorieren"; "HockeyIgnore" = "Ignorieren";
"HockeyShowUpdate" = "Anzeigen"; "HockeyShowUpdate" = "Anzeigen";
"HockeyInstallUpdate" = "Installieren"; "HockeyInstallUpdate" = "Installieren";

View File

@ -63,6 +63,7 @@
"HockeyNoUpdateNeededTitle" = "No Update Available"; "HockeyNoUpdateNeededTitle" = "No Update Available";
"HockeyNoUpdateNeededMessage" = "%@ is already the latest version."; "HockeyNoUpdateNeededMessage" = "%@ is already the latest version.";
"HockeyUpdateAlertTextWithAppVersion" = "%@ is available."; "HockeyUpdateAlertTextWithAppVersion" = "%@ is available.";
"HockeyUpdateAlertMandatoryTextWithAppVersion" = "%@ is available and is a mandatory update!";
"HockeyIgnore" = "Ignore"; "HockeyIgnore" = "Ignore";
"HockeyShowUpdate" = "Show"; "HockeyShowUpdate" = "Show";
"HockeyInstallUpdate" = "Install"; "HockeyInstallUpdate" = "Install";

View File

@ -63,6 +63,7 @@
"HockeyNoUpdateNeededTitle" = "Nessun aggiornamento disponibile"; "HockeyNoUpdateNeededTitle" = "Nessun aggiornamento disponibile";
"HockeyNoUpdateNeededMessage" = "%@ <20> aggiornata all'ultima versione."; "HockeyNoUpdateNeededMessage" = "%@ <20> aggiornata all'ultima versione.";
"HockeyUpdateAlertTextWithAppVersion" = "%@ <20> disponibile."; "HockeyUpdateAlertTextWithAppVersion" = "%@ <20> disponibile.";
"HockeyUpdateAlertMandatoryTextWithAppVersion" = "%@ is available and is a mandatory update!";
"HockeyIgnore" = "Ignora"; "HockeyIgnore" = "Ignora";
"HockeyShowUpdate" = "Mostra"; "HockeyShowUpdate" = "Mostra";
"HockeyInstallUpdate" = "Installa"; "HockeyInstallUpdate" = "Installa";

View File

@ -64,6 +64,7 @@
"HockeyNoUpdateNeededTitle" = "Ingen uppdatering tillgänglig"; "HockeyNoUpdateNeededTitle" = "Ingen uppdatering tillgänglig";
"HockeyNoUpdateNeededMessage" = "%@ är den senaste versionen."; "HockeyNoUpdateNeededMessage" = "%@ är den senaste versionen.";
"HockeyUpdateAlertTextWithAppVersion" = "%@ finns."; "HockeyUpdateAlertTextWithAppVersion" = "%@ finns.";
"HockeyUpdateAlertMandatoryTextWithAppVersion" = "%@ is available and is a mandatory update!";
"HockeyIgnore" = "Ignorera"; "HockeyIgnore" = "Ignorera";
"HockeyShowUpdate" = "Visa"; "HockeyShowUpdate" = "Visa";
"HockeyInstallUpdate" = "Installera"; "HockeyInstallUpdate" = "Installera";