[英]How do I have my program send customer's log file data from their iPhone/iPad?
I am writing an enterprise client/server application. 我正在编写企业客户端/服务器应用程序。 The client is an iOS app which uses Cocoa Lumberjack to create the log files. 客户端是一个iOS应用程序,它使用Cocoa Lumberjack来创建日志文件。 These files will be essential for client debugging and troubleshooting. 这些文件对于客户端调试和故障排除至关重要。 The file will be a maximum of 1MB, although making it smaller is an option. 该文件最大为1MB,但可以选择较小的文件。
I planned to code a "email log file" button but I can't figure out how to send it as an attachment. 我打算编写一个“电子邮件日志文件”按钮,但我无法弄清楚如何将其作为附件发送。 I suppose I could stuff the email's body with all my log messages, but that seems a bit ugly. 我想我可以用我所有的日志消息填充电子邮件的正文,但这看起来有点难看。 What if I want to compress the file into a non-text format before sending? 如果我想在发送之前将文件压缩为非文本格式,该怎么办? I've also considered creating a web service to upload the log file to the server but this seems like a lot of work, as I would then need to sort out who's log file is who's and have some kind of purge to keep it neat, etc. 我还考虑过创建一个Web服务来将日志文件上传到服务器,但这似乎需要做很多工作,因为我需要弄清楚谁的日志文件是谁,并进行某种清除以保持整洁,等等
Surely I'm not the first to face this issue. 当然,我不是第一个面对这个问题的人。 How is everyone else doing this? 别人怎么做这个?
Thanks in advance for any help you can give me. 在此先感谢您提供给我的任何帮助。
Here's some complete working code that creates an email, adds a HTML body, adds a text attachment, and sends shows the compose view. 这里有一些完整的工作代码,用于创建电子邮件,添加HTML正文,添加文本附件以及发送显示撰写视图。
Make sure you also define path for resource. 确保您还定义资源的路径。
NSData *textData = [[self getEmailAttachment] dataUsingEncoding:NSUTF8StringEncoding];
NSString *htmlData = [self getEmailBodyHTML];
/* Set up the mail compose view and put in the body/attachment */
MFMailComposeViewController *mailComposer = [[[MFMailComposeViewController alloc] init] autorelease];
[mailComposer setMessageBody:htmlData isHTML:NO];
[mailComposer addAttachmentData:textData mimeType:@"text/plain" fileName:@"logfile.txt"];
/* Set default subject */
[mailComposer setSubject:@"Email subject"];
mailComposer.mailComposeDelegate = self;
[self presentModalViewController:mailComposer animated:YES];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.