开发者

iPhone Application Error Submit

I have an application that is about to go into testing that, upon开发者_开发知识库 reload after a crash, displays a UIAlertView with a text field that asks what the user was doing when the application crashed.

How can I take what the user puts in that UIAlertView text field and submit it to me? Email sounded great, but then they would have to leave the application for that and it seems inefficient. So something that would be more seamless.

Thanks in advance.


They don’t have to leave the app to email you. Check out the MFMailComposeViewController class.


The easiest way to do this without resorting to e-mail is probably to build a simple web service which accepts an HTTP POST containing the details of the crash. Your web service can store those details in a database or flat file which you can access as needed.

POSTing from the iPhone to a web service is pretty easy. If you want to write the code yourself, I'd recommend checking out the NSURLConnection documentation. However, there's an even easier way to do it, as described in this answer: use the ASIHTTPRequest library to do the whole thing in just a few lines of code. This example code from the ASIHTTPRequest site describes how to POST a series of keys and values.

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"Ben" forKey:@"first_name"];
[request setPostValue:@"Copsey" forKey:@"last_name"];
[request setFile:@"/Users/ben/Desktop/ben.jpg" forKey:@"photo"];

As for how to write the web service, here's a good tutorial on writing a simple PHP/MySQL web service, geared specifically towards iOS development. Of course, you will need a server for this, but hosting is cheap and this will definitely be the best way for you to collect data. (You could also use Google App Engine for free, but I've heard some bad things about App Engine's performance.)

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜