mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 13:13:55 +00:00
Provide a delegate method to disable crash reporting instead of using a property
This commit is contained in:
parent
141d9e5890
commit
93bd10ced5
@ -95,7 +95,7 @@ typedef enum BITCrashStatus {
|
||||
NSFileManager *_fileManager;
|
||||
|
||||
BOOL _crashIdenticalCurrentVersion;
|
||||
BOOL _crashReportActivated;
|
||||
BOOL _crashReportDisabled;
|
||||
|
||||
NSMutableArray *_crashFiles;
|
||||
|
||||
|
||||
@ -99,16 +99,12 @@
|
||||
_analyzerStarted = 0;
|
||||
}
|
||||
|
||||
testValue = nil;
|
||||
testValue = [[NSUserDefaults standardUserDefaults] stringForKey:kBITCrashActivated];
|
||||
if (testValue) {
|
||||
_crashReportActivated = [[NSUserDefaults standardUserDefaults] boolForKey:kBITCrashActivated];
|
||||
} else {
|
||||
_crashReportActivated = YES;
|
||||
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithBool:YES] forKey:kBITCrashActivated];
|
||||
_crashReportDisabled = NO;
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(shouldDisableCrashManager:)]) {
|
||||
_crashReportDisabled = [self.delegate shouldDisableCrashManager:self];
|
||||
}
|
||||
|
||||
if (_crashReportActivated) {
|
||||
if (!_crashReportDisabled) {
|
||||
_crashFiles = [[NSMutableArray alloc] init];
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
_crashesDir = [[NSString stringWithFormat:@"%@", [[paths objectAtIndex:0] stringByAppendingPathComponent:@"/crashes/"]] retain];
|
||||
@ -295,7 +291,7 @@
|
||||
}
|
||||
|
||||
- (BOOL)hasPendingCrashReport {
|
||||
if (_crashReportActivated) {
|
||||
if (!_crashReportDisabled) {
|
||||
if ([_crashFiles count] == 0 && [self.fileManager fileExistsAtPath:_crashesDir]) {
|
||||
NSString *file = nil;
|
||||
NSError *error = NULL;
|
||||
|
||||
@ -37,6 +37,24 @@
|
||||
|
||||
@optional
|
||||
|
||||
|
||||
///-----------------------------------------------------------------------------
|
||||
/// @name Configuration
|
||||
///-----------------------------------------------------------------------------
|
||||
|
||||
/** Return YES if you the crash reporting module should be disabled
|
||||
|
||||
The crash reporting module is enabled by default. Implement this delegate and
|
||||
return NO if you want to disable it.
|
||||
|
||||
If you intend to implement a user setting to let them enable or disable
|
||||
crash reporting, this delegate should be used to return that value.
|
||||
|
||||
@param crashManager The `BITCrashManager` instance invoking this delegate
|
||||
*/
|
||||
- (BOOL)shouldDisableCrashManager:(BITCrashManager *)crashManager;
|
||||
|
||||
|
||||
///-----------------------------------------------------------------------------
|
||||
/// @name Additional meta data
|
||||
///-----------------------------------------------------------------------------
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user