Fengson
Fengson

Reputation: 4912

How to disable Crashlytics for iOS during a runtime?

Following this tutorial I am able to integrate Crashlytics into an iOS project.

However, I would like to disable tracking when users that log in are from our company (by checking email domain for logged user) and only track our clients.

Is it possible to disable Crashlytics based on some conditionals once the app is running? I couldn't find this option in docs.

Upvotes: 2

Views: 1556

Answers (1)

Maxim Pavlov
Maxim Pavlov

Reputation: 2972

You can't disable it during a runtime, however, you can prevent it from sending particular crash reports, using technique, described in the documentation:

First, you must set the Crashlytics delegate in the following order:

CrashlyticsKit.delegate = self;
[Fabric with:@[[Crashlytics class]]];

and implement delegate method:

- (void)crashlyticsDidDetectReportForLastExecution:(CLSReport *)report completionHandler:(void (^)(BOOL))completionHandler {
    // You must set email to CrashlyticsKit, during previous app session, like this:
    // [CrashlyticsKit setUserEmail:userEmail];
    BOOL shouldSendCrashReport = [report.userEmail containsString:@"yourCompanyDomain"];
    completionHandler(shouldSendCrashReport);
}

Upvotes: 1

Related Questions