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!