Problem with integration PLCrashReporter and Unity3D

Hi! I wanna send reports about crashes in iOS app caused by low memory (probably other crashes). I found PLCrashReporter framework which handles Unix low level signals and save crash report onto disk. When I launch the app next time I can read crash report and send it via email for example. I have created simple iOS project (not Unity3D) and successfully send my crash report. It works. But when I create Unity3D project with iOS plugin is responsible for reporting it doesn’t work (method hasPendingCrashReport returns false after I run my app second time like crash report hasn’t been saved). Have anybody had similar problem yet?

This is plugin is responsible for crash reporting. I use plcrashreporter-1.1-rc1.

@implementation CrashReportPlugin

+ (void)load {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkCrashReport:)
        name:UIApplicationDidFinishLaunchingNotification object:nil];
}

+ (void) checkCrashReport:(NSNotification *)notification {
    PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
    NSError *error;
    
    if ([crashReporter hasPendingCrashReport])
        [self handleCrashReport];
    
    if (![crashReporter enableCrashReporterAndReturnError: &error])
        NSLog(@"Warning: Could not enable crash reporter: %@", error);
}

+ (void) handleCrashReport {
    PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
    NSData *crashData = NULL;
    NSError *error = NULL;
   
     crashData = [crashReporter loadPendingCrashReportDataAndReturnError: &error];
     if (crashData == nil) {
         [crashReporter purgePendingCrashReport];
         return;
     }
     
    PLCrashReport *report = [[[PLCrashReport alloc] initWithData: crashData error: &error] autorelease];
    if (report == nil) {
         [crashReporter purgePendingCrashReport];
         return;
     }
    
    PLCrashReportTextFormat textFormat = PLCrashReportTextFormatiOS;
    NSString* log = [PLCrashReportTextFormatter stringValueForCrashReport: report withTextFormat: textFormat];
    NSData* data = [log dataUsingEncoding:NSUTF8StringEncoding];
     
    // Send report via email

    [crashReporter purgePendingCrashReport];
}

Thanks in advance!

The problem is solved. It seems that mono runtime set up its own signal handlers and handlers from PLCrashReporter isn’t called. When I initialized PLCrashReporter after C# scripts were started (after full initialization of mono environment) I successfully intercepted a crash.

hi ! I Learn the blog,but i don’t know where to call the load function . Thanks!

In case anybody is still trying to figure out how to do this, I solved it by initializing PLCrashReporter in the “applicationDidBecomeActive” callback.

This callback is called once Mono has finished initializing all its libraries and dependencies and when you setup PLCrashReporter in this callback, it is able to override the Signals & Event Handlers that Unity3D sets up.