我从application_did_finish_launching_with选项调用handle_crash_report。还实现了handle_crash_report。现在我通过邮件发送崩溃日志。 以下是我正在使用的代码。
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil) {
MFMailComposeViewController *picker1 = [[MFMailComposeViewController alloc] init];
picker1.mailComposeDelegate = self;
picker1.modalPresentationStyle = UIModalPresentationFormSheet;
[picker1 setSubject:@"log files"];
// Set the recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"telekomsrbija.android@gmail.com"];
[picker1 setToRecipients:toRecipients];
//First File
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *fileName = [documentsDirectory stringByAppendingPathComponent:@"debug_log.txt"];
NSData *myNoteData = [NSData dataWithContentsOfFile:fileName];
if ([myNoteData length])
[picker1 addAttachmentData:myNoteData mimeType:@"text/plain" fileName:@"debug_log.txt"];
然后我正在检查CrashHelper是否有crashReportPending。它有这个代码。
if ([CrashHelper hasCrashReportPending]) {
NSData* crashData = [NSData dataWithContentsOfFile:[CrashHelper sharedCrashHelper].getCrashPath];
[picker1 addAttachmentData:crashData mimeType:@"text/plain" fileName:@"LastCrashReports.txt"];
}
NSString *emailBody = @"I am attaching my file!";
[picker1 setMessageBody:emailBody isHTML:NO];
if([mailClass canSendMail]) {
[self.navigationController presentViewController:picker1 animated:YES completion:nil];
}
}
答案 0 :(得分:1)
无法直接从设备获取包含类名,方法名,文件名和行号的完全符号化崩溃报告。您需要使用服务器或Mac上的操作系统,应用程序和框架符号来表示崩溃报告。
有很多问题和答案已经详细描述了这个过程。例如this one