Skip to content

Commit

Permalink
Merge pull request #3 from joshuafeldman/master
Browse files Browse the repository at this point in the history
Ticket #2 - First time app launch always reports TBTerminationTypeFor…
  • Loading branch information
JesseCrocker committed Dec 23, 2015
2 parents e777348 + 9cb30c6 commit 586a515
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions TBOOMDetector/TBOOMDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

typedef NS_ENUM(NSInteger, TBTerminationType) {
TBTerminationTypeUnknown = -1,
TBTerminationTypeAppLaunchAfterFirstInstall,
TBTerminationTypeAppUpdate,
TBTerminationTypeExit,
TBTerminationTypeCrash,
Expand Down
17 changes: 16 additions & 1 deletion TBOOMDetector/TBOOMDetector.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ - (void)runChecks:(void (^)(TBTerminationType terminationType))callback; {
}

TBTerminationType terminationType = TBTerminationTypeUnknown;
if([self checkAppUpdated:launchState]) {
if([self checkAppLaunchAfterFirstInstall:launchState]) {
terminationType = TBTerminationTypeAppLaunchAfterFirstInstall;
} else if([self checkAppUpdated:launchState]) {
terminationType = TBTerminationTypeAppUpdate;
} else if([self checkAbortOrExit]) {
terminationType = TBTerminationTypeExit;
Expand Down Expand Up @@ -124,6 +126,17 @@ - (void)runChecks:(void (^)(TBTerminationType terminationType))callback; {
}


- (BOOL)checkAppLaunchAfterFirstInstall:(NSDictionary*)launchState {
NSString *lastVersion = launchState[AppVersionKey];

if(lastVersion == nil) {
return YES;
} else {
return NO;
}
}


- (BOOL)checkAppUpdated:(NSDictionary*)launchState {
NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
NSString *lastVersion = launchState[AppVersionKey];
Expand Down Expand Up @@ -216,6 +229,8 @@ + (NSString*)stringFromTBTerminationType:(TBTerminationType)terminationType {
switch (terminationType) {
case TBTerminationTypeUnknown:
return @"TBTerminationTypeUnknown";
case TBTerminationTypeAppLaunchAfterFirstInstall:
return @"TBTerminationTypeAppLaunchAfterFirstInstall";
case TBTerminationTypeAppUpdate:
return @"TBTerminationTypeAppUpdate";
case TBTerminationTypeExit:
Expand Down

0 comments on commit 586a515

Please sign in to comment.