Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIActivityViewController - Mail Activity - How to set email recipients and subject? [duplicate]

I'm using the new UIActivityViewController class in iOS6 to provide the user with various sharing options. You can pass an array of parameters to it such as text, links and images and it does the rest.

How do I define recipients? For example sharing via mail or SMS should be able to accept recipients but I can't figure out how to invoke this behaviour.

I don't want to have to have to use MFMessageComposeViewController and UIActivityViewController separately as that just defeats the purpose of the share controller.

Any suggestions?

UIActivityViewController Class Reference

Edit: This has now been submitted Apple and subsequently merged with a duplicate bug report.

Bug report on OpenRadar

like image 932
MattCheetham Avatar asked Nov 25 '22 12:11

MattCheetham


1 Answers

For adding subject to the email using UIActivityViewController on iOS6, this is the best solution that anyone can use.. All you have to do is call the following while initializing UIActivityViewController.

UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
[activityViewController setValue:@"My Subject Text" forKey:@"subject"];

And your UIActivityViewController is populated with a subject.

like image 191
Ajay Avatar answered Dec 09 '22 12:12

Ajay