Add a Crash Reporting Callback

You may want to make crash report information that Mobile RUM collects available to other parts of your code, for example, to Google Analytics, if you are using it. To enable you to pass on summary crash information, you can set up a crash report runtime callback. To get a callback when the iOS Agent detects and then reports a crash, you need to implement the following protocol in your code:

@protocol ADEumCrashReportCallback <NSObject>
  
- (void)onCrashesReported:(NSArray<ADEumCrashReportSummary *> *)crashReportSummaries;
  
@end
Warning: This callback is invoked on your app's UI thread, so any significant work should be done on a separate work thread.

Each ADEumCrashReportSummary passed in has the following properties:

@interface ADEumCrashReportSummary : NSObject
 
/** Uniquely defines the crash, can be used as key to find full crash report. */
@property (nonatomic, readonly) NSString *crashId;
 
/** The exception name, may be `nil` if no `NSException` occured. */
@property (nonatomic, readonly) NSString * ADEUM_NULLABLE exceptionName;
 
/** The exception reason, may be `nil` if no `NSException` occured. */
@property (nonatomic, readonly) NSString * ADEUM_NULLABLE exceptionReason;
 
/** The Mach exception signal name */
@property (nonatomic, readonly) NSString *signalName;
 
/** The Mach exception signal code */
@property (nonatomic, readonly) NSString *signalCode;
 
@end

If you are sending the information to another analytics tool, such as Google Analytics, it is best to include all five properties:

  • exceptionName and exceptionReason are optional and useful for a quick identification of what the crash is. These are only present if the crash cause occurred within an exception reporting runtime, such as Objective-C.
  • signalName and signalCode are useful for quick identification of the crash. These are from the system and are independent of the runtime.
  • For additional information, crashId can be used to look up the crash in the Controller UI.

For example, to print the crash information to iOS's logger, you could implement an ADEumCrashReportCallback class like this:

// assumes the containing object has "adopted" the protocol
- (void)onCrashesReported:(NSArray<ADEumCrashReportSummary *> *)summaries {
    for (ADEumCrashReportSummary *summary in summaries) {
        NSLog(@"Crash ID: %@", summary.crashId);
        NSLog(@"Signal: %@ (%@)", summary.signalName, summary.signalCode);
        NSLog(@"Exception Name:\n%@", summary.exceptionName);
        NSLog(@"Exception Reason:\n%@", summary.exceptionReason);
    }
}

You set the object that implements the ADEumCrashReportCallback protocol during agent configuration:

ADEumAgentConfiguration *config = [ADEumAgentConfiguration new];
config.crashReportCallback = myCrashReportCallback;

Your callback is invoked, on the main/UI thread, if a crash from a previous run is detected and collected. See the latest iOS SDK documentation.