简体   繁体   中英

iPhone4 iOS5 what is the best way to create a mailing list with a UIViewController?

I'm trying to offer the users of my app an opportunity to join a mailing list to receive news about the product updates. This way, I hope to re-capture some of the users who might've stopped using my app at some point in the future.

I know how to display an email composition sheet with a pre-defined email address, but something tells me that there has to be a better way than asking the user to send me an email to join the list.

Has anyone done something like that for iPhone? What kind of code would I need to run on my website to capture these emails and automatically add them to a mailing list? I can add some PHP scripts to my pages, but I'm a total amateur when it comes to web programming and PHP.

Thank you!

I think you should use ASIHTTPRequest library - it will allow you to run very simple queries using POST. You can use ios as well, but I found ASIHTTPRequest much easier.

Now, you need a php script on the server, sth like (very basic stuff):

store.php:

<?
$email = $_POST['email'];
// for now we send email to confir script work
mail($email, 'GREAT!', "YOU SIGNED FOR OUR NEWSLETTER, WE WILL SPAM YOU"); 
printf("OK"); // output we can read via ASIHTTP

// here should be be code for storing $email var in database / text file
?> 

so now you need to request http://www.myserver.com/store.php with some extra POST arguments, sth like:

NSURL *url = [NSURL URLWithString:@"http://www.myserver.com/store.php"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
// email is variable name, we read it in php script
[request setPostValue:@"jdoe@mail.com" forKey:@"email"];  
[request startSynchronous];  // you should use async here

I've tested similar solution recently, it works. Happy coding

I agree with Siegfried, but you could also look into MailChimp and there Objective-C API wrapper ChimpKit . The only reason I suggest this, is you don't have to worry about all the unsubscribe/management and such. It's simple enough to implement, and it saves you the headache of setting up and writing the web-side.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM