-5

I need to have my users fill out a form, and send me the information. Nothing fancy, just their name and email, and they'd be doing it willingly.

I looked into emailing the information to my account, but it seems like you have to pop the MFMailComposeViewController and let the user submit an email -- and I don't want to bother them with that.

I also tried a simple mailto url, like this:

NSString *url = @"mailto:example@example.com?&subject=Greetings from Cupertino!&body=Wish you were here!";
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];

But it doesn't work on my simulator, or my iPhone, which is 4s with iOS 6.

I also looked into creating a google doc, and have the application send the user's info to its URL, but I'm assuming the result would be similar to the mailto URL?

So is there a good, simple way to do it?

Eddy
  • 3,533
  • 13
  • 59
  • 89
  • 3
    Can you send this data by sending post request? Why do you need to mail? – Tala Aug 05 '13 at 12:47
  • See if you wont open the mail where will add the email address ? – IronManGill Aug 05 '13 at 12:48
  • @Tala I can do a post. Is that possible with iOS? (I'm on my first app and not sure what is Apple's policy.) – Eddy Aug 05 '13 at 12:49
  • 1
    @Eddy I see, this is usually done over network without mailing. Read this https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol and this https://github.com/AFNetworking/AFNetworking – Tala Aug 05 '13 at 12:51
  • So basically the answer is that Apple won't throw me out of the store for doing an HTTP post. – Eddy Aug 05 '13 at 12:56
  • 1
    @Eddy No, of course they won't. What ever gave you that idea? iOS apps use web services all the time. People fill out forms in Mobile Safari all the time. POST is a perfectly legitimate thing to do. (If you're not sure about Apple's policy, read your developer agreement and the App Store guidelines.) – Caleb Aug 05 '13 at 13:00

2 Answers2

2

So is there a good, simple way to do it?

Sure -- but not using mail. Use HTTP instead, and POST the data to a web server. If you need to collect the results by mail, you could easily create an e-mail message on the server and send from there, but it seems more likely that you'll just want to add the information to a database directly.

To use HTTP, you'll create a NSURLRequest with the relevant parameters and then send it using NSURLConnection. If you don't feel like digging into the URL loading system that iOS provides, there are a number of wrapper libraries that make it even easier. But for what you want to do, using NSURLConnection directly will be pretty straightforward.

Caleb
  • 124,013
  • 19
  • 183
  • 272
1

Maybe you should have a look at these links :-

How to send mail from iphone app without showing MFMailComposeViewController?

Send mail without MFMailComposeViewController

Sending Email without using MFMailComposeViewController

MFMailComposer send email without presenting view

Community
  • 1
  • 1
IronManGill
  • 7,222
  • 2
  • 31
  • 52
  • So basically the answer is I have to do an HTTP post? And Apple won't throw me out of the store for doing it? (btw I'm not sure why did anyone down voted your answer, it helped me and I'm upping it.) – Eddy Aug 05 '13 at 12:57