Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ios中发送崩溃报告日志文件_Ios_Iphone_Mfmailcomposeviewcontroller - Fatal编程技术网

在ios中发送崩溃报告日志文件

在ios中发送崩溃报告日志文件,ios,iphone,mfmailcomposeviewcontroller,Ios,Iphone,Mfmailcomposeviewcontroller,我想允许用户发送应用程序崩溃日志文件的电子邮件。问题是,从我的设备,我可以发送日志文件作为电子邮件附件。但从一些设备我收到电子邮件,但没有附加的日志文件。 我使用以下代码发送电子邮件日志文件 if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; ma

我想允许用户发送应用程序崩溃日志文件的电子邮件。问题是,从我的设备,我可以发送日志文件作为电子邮件附件。但从一些设备我收到电子邮件,但没有附加的日志文件。 我使用以下代码发送电子邮件日志文件

if ([MFMailComposeViewController canSendMail])
    {
        MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];

        mailer.mailComposeDelegate = self;

        [mailer setSubject:@"Application Logs File"];

        NSArray *toRecipients = [NSArray arrayWithObjects:@"my Email ID", nil];
        [mailer setToRecipients:toRecipients];

        NSData *fileData = [NSData dataWithContentsOfFile:[Utility getCurrentLogsFileNameFromUserDefaults]];
        NSString* theFileName = [[Utility getCurrentLogsFileNameFromUserDefaults] lastPathComponent];
        NSLog(@"File Data %@",theFileName);

        [mailer addAttachmentData:fileData mimeType:@"text/x-log" fileName:theFileName];

        NSString *emailBody = @"PFA for logs file.";
        [mailer setMessageBody:emailBody isHTML:NO];

        [self presentViewController:mailer animated:YES completion:nil];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
                                                        message:@"Your device doesn't support the composer sheet"
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
        [alert show];
    }

函数getCurrentLogsFileNameFromUserDefaults中有什么?它将获取存储在user defaults.NSLog@%@[实用程序getCurrentLogsFileNameFromUserDefaults]中的日志文件名;这将向您发送一个文件路径,然后检查该路径上是否存在任何文件。我可以在我的设备上进行测试。但是如何在其他设备上检查呢?对于其他设备,您应该检查您要发送的文件是否在设备上,然后发送它,否则发送一封电子邮件,说明文件不在设备上。可能是崩溃日志没有写入其中,或者您在UserDefaults中存储了错误的文件名。