How to disable Crashlytics for iOS during a runtime?

独自空忆成欢 提交于 2019-12-12 18:16:49

问题


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.


回答1:


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);
}


来源:https://stackoverflow.com/questions/39390279/how-to-disable-crashlytics-for-ios-during-a-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!