MFMailComposeViewController : subject/text non editable? - objective-c

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.

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.

How to share with messages, mail, print and copy

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.

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)

Make input in program input value at website

I want a function in my JavaFX 2.0 program that takes user input and forwards it to a websites textfield, and then get the value the website returns. The website would be a site to check if the warranty for a spesific program is valid.
All the user would need to input is reg. ID and maybe program brand.
I'm just looking for ideas on how to do this, links or even code would be superb. I suspect it won't require that much code, but hey.. i've been surprised before!
Thanks! :)
A possible implementation algorithm:
Load the warranty check page in the WebView.
Monitor the webEngine.documentProperty to check for when the load has finished.
When the load has finished, use webEngine.executeScript to set the text field to the
required value and submit the form.
EITHER
a. monitor the webEngine.documentProperty some more, and, when the document has loaded, inspect the document (using either JavaScript or Java) to see if the warranty is valid.
OR
b. change the resultant warranty display page to call back into Java and notify your app of the warranty status.
Some background info
If you have control over the website page contents, then your implementation may turn out easier. But I think you should still be able to get the result you want without modifying the website.
There were some additions to the recent JavaFX 2.1 release to facilitate callbacks from Javascript to Java. The webview documentation you want to read is the sections "Processing JavaScript Commands" using the webEngine.executeScript method and "Making Upcalls from JavaScript to JavaFX" using JSObject.setMember.
You might want to also take a look at a Sample DatePicker for JavaFX using jQuery UI example I wrote. It demonstrates various methods for loading html into a WebView, invoking functions on the WebView from Java and getting the results of user interactions with the WebView back into Java. Not exactly what you are looking for, but perhaps the ideas in it may help.
Another option you have is just to:
Accept the registration id in a JavaFX control.
Create a java.net.URL and post to the webserver from your java app directly without using a WebView.
Parse the response from the webserver to extract out whether the warranty is valid.
This is the approach I might take for such a task - eliminating the use of WebView completely.

Check recipient email address with MFMailComposeViewController

I have a question about the MFMailComposeViewController for sending an Email in an app. Is it possible to check the recipient adress before sending the email ?
I did not find any response so i think it's not possible..
If it's not possible, there is other solution ?
When you present the MFMailComposeViewController you lose complete control over it.
You can't do anything with it, neither get the "To" email address nor prevent the sending of the mail.
From the 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.