From 69f06c7cb2ff5a4656b9d5aafc018d17a458403f Mon Sep 17 00:00:00 2001 From: Anna Johnson Date: Mon, 12 Dec 2016 12:29:39 -0800 Subject: [PATCH] Make appWasBackgroundedOnExist a visible property This is useful to show messaging in app, before crashlytics has loaded to determine what type of crash it was. --- TBOOMDetector/TBOOMDetector.h | 1 + TBOOMDetector/TBOOMDetector.m | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TBOOMDetector/TBOOMDetector.h b/TBOOMDetector/TBOOMDetector.h index 86322df..bafc442 100644 --- a/TBOOMDetector/TBOOMDetector.h +++ b/TBOOMDetector/TBOOMDetector.h @@ -25,6 +25,7 @@ typedef NS_ENUM(NSInteger, TBTerminationType) { @interface TBOOMDetector : NSObject @property (nonatomic, readonly) TBTerminationType lastTerminationType; +@property (nonatomic, readonly) BOOL appWasBackgroundedOnExit; - (instancetype)initWithCrashlyticsApiKey:(NSString*)apiKey directory:(NSString*)directory diff --git a/TBOOMDetector/TBOOMDetector.m b/TBOOMDetector/TBOOMDetector.m index d16397a..9cb2b46 100644 --- a/TBOOMDetector/TBOOMDetector.m +++ b/TBOOMDetector/TBOOMDetector.m @@ -15,7 +15,6 @@ @interface TBOOMDetector () { NSString *backgroundStateFile; NSString *terminationEventFileContents; BOOL crashWasDetected; - BOOL appWasBackgroundedOnExit; NSString *stateDirectory; } @@ -63,10 +62,10 @@ - (instancetype)initWithCrashlyticsApiKey:(NSString*)apiKey } backgroundStateFile = [directory stringByAppendingString:@"OOMDetectorBackgroundState.bool"]; - appWasBackgroundedOnExit = NO; + _appWasBackgroundedOnExit = NO; if([[NSFileManager defaultManager] fileExistsAtPath:backgroundStateFile]) { [[NSFileManager defaultManager] removeItemAtPath:backgroundStateFile error:nil]; - appWasBackgroundedOnExit = YES; + _appWasBackgroundedOnExit = YES; } //Wait for crashlytics to run, so we know if there was a crash @@ -103,7 +102,7 @@ - (void)runChecks:(void (^)(TBTerminationType terminationType))callback; { } else if ([terminationEventFileContents isEqualToString:@"debugger"]) { terminationType = TBTerminationTypeDebugger; } else { - if(appWasBackgroundedOnExit) { + if(_appWasBackgroundedOnExit) { NSLog(@"Detected Background OOM"); terminationType = TBTerminationTypeBackgroundOom; } else {