CrashlyticsDelegate

@protocol CrashlyticsDelegate

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.

    Warning

    Failure to invoke the completionHandler will prevent submissions from being reported. Watch out.

    Warning

    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.

    Declaration

    Swift

    optional func crashlyticsDidDetectReport(forLastExecution report: CLSReport, completionHandler: @escaping (Bool) -> Void)

    Objective-C

    - (void)crashlyticsDidDetectReportForLastExecution:(nonnull CLSReport *)report
                                     completionHandler:
                                         (nonnull void (^)(BOOL))completionHandler;

    Parameters

    report

    The CLSReport object representing the last detected report

    completionHandler

    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.

    Declaration

    Swift

    optional func crashlyticsDidDetectReport(forLastExecution report: CLSReport)

    Objective-C

    - (void)crashlyticsDidDetectReportForLastExecution:(nonnull CLSReport *)report;

    Parameters

    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.

    Warning

    Background submission is not supported for extensions on iOS or OS X.

    Declaration

    Swift

    optional func crashlyticsCanUseBackgroundSessions(_ crashlytics: Crashlytics) -> Bool

    Objective-C

    - (BOOL)crashlyticsCanUseBackgroundSessions:(nonnull Crashlytics *)crashlytics;

    Parameters

    crashlytics

    The Crashlytics singleton instance

    Return Value

    Return NO if you don’t want out-of-process background network operations.