The CrashlyticsDelegate protocol provides a mechanism for your application to take action on events that occur in the Crashlytics crash reporting system. You can make use of these calls by assigning an object to the Crashlytics’ delegate property directly, or through the convenience +startWithAPIKey:delegate: method.
Called when a Crashlytics instance has determined that the last execution of the application resulted in a saved report. This is called synchronously on Crashlytics initialization. Your delegate must invoke the completionHandler, but does not need to do so synchronously, or even on the main thread. Invoking completionHandler with NO will cause the detected report to be deleted and not submitted to Crashlytics. This is useful for implementing permission prompts, or other more-complex forms of logic around submitting crashes.
Instead of using this method, you should try to make use of -crashlyticsDidDetectReportForLastExecution: if you can.
Failure to invoke the completionHandler will prevent submissions from being reported. Watch out.
Just implementing this delegate method will disable all forms of synchronous report submission. This can impact the reliability of reporting crashes very early in application launch.
optional func crashlyticsDidDetectReport(forLastExecution report: CLSReport, completionHandler: @escaping (Bool) -> Void)
- (void)crashlyticsDidDetectReportForLastExecution:(nonnull CLSReport *)report completionHandler: (nonnull void (^)(BOOL))completionHandler;
The CLSReport object representing the last detected report
The completion handler to call when your logic has completed.
Called when a Crashlytics instance has determined that the last execution of the application resulted in a saved report. This method differs from -crashlyticsDidDetectReportForLastExecution:completionHandler: in three important ways:
- it is not called synchronously during initialization - it does not give you the ability to prevent the report from being submitted - the report object itself is immutable
Thanks to these limitations, making use of this method does not impact reporting reliabilty in any way.
optional func crashlyticsDidDetectReport(forLastExecution report: CLSReport)
- (void)crashlyticsDidDetectReportForLastExecution:(nonnull CLSReport *)report;
The read-only CLSReport object representing the last detected report
If your app is running on an OS that supports it (OS X 10.9+, iOS 7.0+), Crashlytics will submit most reports using out-of-process background networking operations. This results in a significant improvement in reliability of reporting, as well as power and performance wins for your users. If you don’t want this functionality, you can disable by returning NO from this method.
Background submission is not supported for extensions on iOS or OS X.
optional func crashlyticsCanUseBackgroundSessions(_ crashlytics: Crashlytics) -> Bool
- (BOOL)crashlyticsCanUseBackgroundSessions:(nonnull Crashlytics *)crashlytics;
The Crashlytics singleton instance
Return NO if you don’t want out-of-process background network operations.