How to share with messages, mail, print and copy - objective-c

I've seen some apps that allow you to share content with ios's mail, messages, print and copy.
I see there is a project called sharekit that does something similar but integrates social network sharing. Personally I don't need the social sharing, so sharekit it probably overkill.
I just need to popup an actionsheet that will allowe me to pass some text for example to the mail app or the messages app.

What you are looking for is the MessageUI.framework.
This framework contains:
MFMailComposeViewController
this class will allow your user to compose an e-mail.
MFMessageComposeViewController this class will allow your to compose a SMS message. MMS is not supported.
You will have to write the action sheet you self, but after the user made there choice you can create an instance of MFMailComposeViewController or MFMessageComposeViewController and present it to the user.
Be aware that you will need to implement the MFMailComposeViewControllerDelegate and/or MFMessageComposeViewControllerDelegate to dismiss the view.

Look my answer here:
https://stackoverflow.com/a/13975189/736384
I wrote about the new UIActivity control, It let you do all you are looking for.

If all you want to do is integrate with Mail or Messages, use the MFMailComposeViewController and MFMessageComposeViewController classes respectively.
If you want to add support for Copy, Print, and other such "activities', take a look at the documentation for UIActivity and UIActivityViewController.

Related

How to save the user's email recipients when sending email with UIActivityViewController?

I'm using UIActivityViewController and when the user selects email from the list of options is there a way to save the email recipients that the user inputs?
Do I need to subclass ActivityItemSource as was done here?
I realize getting the email recipients is tricky even with just using MFMailcomposeViewController as in here.
Do I need to subclass MFMailcomposeViewController to save the email recipients that the user inputs?
From the class reference:
Important: The mail composition interface itself is not customizable
and must not be modified by your application. In addition, after
presenting the interface, your application is not allowed to make
further changes to the email content. The user may still edit the
content using the interface, but programmatic changes are ignored.
Thus, you must set the values of content fields before presenting the
interface.
So, no. You should not subclass MFMailcomposeViewController in order to "steal" the email addresses that the user has entered. This is a privacy issue, and Apple specifically designed it this way. If you try to circumvent this, then your app very likely will be (and should be) rejected.

iOS 6 send email without user interaction

First of all, I'm working on an in-house app, so I don't need approval at App Store. I know it wouldn't ever be accepted, but it's a business rule our users share some content of the application, but with a default message and subject, so they can't edit these fields..
Until iOS 5 I was able to navigate by the view hierarchy and let the fields unneditable. But with iOS 6, and the mail on another proccess, I can't do it anymore.
I need to block the views for editing (I put a view over all the mail view, except the title bar, and it works, but when the user try to cancel the e-mail, my view is blocking the popover to delete or save draft too) or send e-mails without the UI (I was able to do it with Stealth Messenger based code (https://github.com/0xced/Stealth-Messenger/) at iOS 4 or 5, but now it doesn't work).
I tryed everything I could with private APIs and Objective-C runtime.. I can dismiss the view with sending e-mail ok, but the e-mail itself isn't sent.
Can anybody help me? Does anybody did it?
Thanks in advance..
Take a look at this: Send Email in Background from iOS
IOS doesn't support to mail in background. [...] As an alternate you
should implement the WebService for this[...]
Probably the best option is to utilise some server code and call that with NSURLRequest.
Hope that helps.
I do this in an app of mine. I have a simple PHP script on a webserver that uses the PearPHP mail modules to send SMTP mail. The PHP script takes a few incoming variables, like $toAddress, $subject, $message and then connects to the SMTP server and sends the mail out.
Unfortunately, you're not allowed to subclass the MFMailComposeViewController, and if you were using some sort of Invisible UIView to block fields, that was just a workaround that's probably been broken. (They did the same thing with being able to insert a "." on the NumberPad keyboard)

MFMailComposeViewController : subject/text non editable?

I need to work on an application able to send a mail with automatic content (subject/text) that the user shouldn't be allowed to edit. Is it possible to do ?
Thanks for your advices
The answer is "no". If you want to use the MFMailComposeViewController class, you have to pay attention to this paragraph in Apple's documentation:
Important The mail composition interface itself is not customizable
and must not be modified by your application. In addition, after
presenting the interface, your application is not allowed to make
further changes to the email content. The user may still edit the
content using the interface, but programmatic changes are ignored.
Thus, you must set the values of content fields before presenting the
interface.
The user can (and should be able to) change anything and everything s/he wishes before they send out an e-mail.
If you don't want to follow those rules Apple set, there are other mail frameworks you can use within your iOS app.

Properties of iOS messenger

I need to build an app such as "Messages" in iPhone, but easier (don't need to send messages to server, only in datebase). I was faced with some questions.
http://www.ibm.com/developerworks/library/x-ioschat/index.html
In this tutorial messages look like TableView, how can I do them such as in iPhone standard messanger (comics speach). And how can I implement bar with camera button, text box and send button (what class is responsible for this)?
You are in luck good sir, there is already a class that can fix you up with this and avoid all the work, it's called AcaniChat (screenshot provided). Or you can even see at Sam Soffle's SSMessagesViewController, he is a well known iOS developer who built this class.
It will definitely help you, if you want to mimic that behavior.

Sent text to notes

I'm trying to add a 'copy to notes' button in my app which sends a text to the notes app of ios. Is there any possible way to integrate this?
I've done some research and didn't find anything and since I've never seen it in an other app I guess it's not possible, but I thought It was worth a question.
Good question. Situations like the one you describe are always handled with URL schemes using the UIApplication method openURL:. For example, to launch the phone app with a specific number you could do:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:1-234-567-8910"];
Or to launch the Mail app:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"mailto:nobody#example.com"];
Just to show a few examples. The Apple URL Scheme Reference document describes all of the various URL schemes to integrate with different system apps. Nowhere in this document does it mention a URL scheme for the built in Notes app. If it were possible to send text to the Notes app, I would expect the document to advertise the fact. While it's not conclusive proof that it's not possible, I still think it should be cited as strong evidence of such.
Note that there are likely several third party note-taking apps that have their own custom URL scheme that may support launching with text.