Is there a way to prevent MFMailComposeViewController from sending an email? - iphone

I use an MFMailComposeViewController in an app to make it easy for the user to send me support requests. However, I get a lot of emails with the default message (+ the user's signature), but without any additional info added. I'm guessing this is because a kid is using the device and they're just mashing buttons. Is there any way to detect this case and have it not send the email?

Unfortunately, this is not possible.
From the apple docs:
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.

Related

Disable phone number parsing in iPhone email subject

Is there a way to prevent iOS / iPhone from parsing a phone number like string in an email subject when sending an email to one of these devices?
Ex. Subject: "Test Email 1234567" results in an undesired phone number link
I've tried the solutions in the following questions, but those only work for links in the body, not the subject
How do you disable phone number linking in iPhone Mail app?
How do you dissable phone number detection in mobile safari
You could access the view and disable data detection, unfortunately you can't do that according to 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.

iPhone: How to disable editing when MFMessageComposeViewController shows up

Is it possible to prevent editing when MFMessageComposeViewController shows up?
'Cause I want the body of SMS can't be changed by user and I think it's still legal.
Please help!
No the user has final say when using the MFMessageComposeView.
Your app is also prohibited from changing the content/recipient/body of the email when the
view slides up.
If you could do this it would be easy to paste in a different recipient, sniff the content provided by the user etc. etc. (especially in the Message App, you could swap the phone number and do terrible things.).
I guess this is the logic behind, you get to pre-populate the message, but the user decides from there on and until "Cancel" or "Send".
You should probably build a web service where you have control over the data
when it hits the server and make an interface for that on the phone.

How to activate mail application (built in in iPhone) through programming? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I send mail from an iPhone application
how to activate mail application (built in in iphone) through programming. I want to quit
my project also?
I can't really be sure by the wording of your question, but it seems like you want to send mail without leaving your application.
In the 3.0 SDK you have access to MFMailComposeViewController, which will bring up a mail window and allow you to send mail while remaining in your application.
From the Apple Docs:
The MFMailComposeViewController class provides a standard interface that manages the editing and sending an email message. You can use this view controller to display a standard email view inside your application and populate the fields of that view with initial values, such as the subject, email recipients, body text, and attachments. The user can edit the initial contents you specify and choose to send the email or cancel the operation.
Using this interface does not guarantee immediate delivery of the corresponding email message. The user may cancel the creation of the message, and if the user does choose to send the message, the message is only queued in the Mail application outbox. This allows you to generate emails even in situations where the user does not have network access, such as in airplane mode. This interface does not provide a way for you to verify whether emails were actually sent.
Before using this class, you must always check to see if the current device is configured to send email at all using the canSendMail method. If the user’s device is not set up for the delivery of email, you can notify the user or simply disable the email dispatch features in your application. You should not attempt to use this interface if the canSendMail method returns NO.
To display the view managed by this view controller, you can use any of the standard techniques for displaying view controllers. However, the most common way to present this interface is do so modally using the presentModalViewController:animated: method. Figure 1 shows the view that is displayed when you present the mail composition interface, with some of the fields already filled in. For more information on displaying the views associated with view controllers, see View Controller Programming Guide for iPhone OS.
Something similar to:
NSString *_recipient = #"someone#email.com";
NSURL *_mailURL = [NSURL URLWithString:[NSString stringWithFormat:#"mailto:%#?subject=My Subject", _recipient]];
[[UIApplication sharedApplication] openURL:_mailURL];
will open the Mail app and create a new message with the subject "My Subject" and the recipient someone#email.com. Just modify this with other headers and content to build the message you need to send.
This is how you can send mail from the iphone app.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"mailto:biranchi#purpletalk.com?cc=youremail#gmail.com&subject=Greetings%20from%20Biranchi!&body=Wish%20you%20were%20here!"]];
If you don't want to quit your app:
iphone app send email

How do I initate an email on the iphone from a view?

I need to be able to give users the ability to call someone or email someone from a certain view in my navigation based app.
I thought I would use an action sheet with the choices and depending on the button pressed allow one or the other to be initiated (I'm simplifying a lot but ...).
I really have several questions.
Assuming this is possible to do, will my app be gone after a phone call is started?
Is there a way for me to launch/push on the stack the same "controller" and "view" that Apple uses for making calls and sending emails? Or am I going to have to code this all myself to look like their app?
I want the user to come back to the same page they were on when the email or phone call was initiated. How can I do that or is my app gone if I use their controller and nib?
Assuming it's possible to do either of these things, can I put the email address I want for a default in the to: field of the email view and if so how?
Here are the answers to your questions:
Assuming this is possible to do, will
my app be gone after a phone call is
started?
Yes.
Is there a way for me to launch/push
on the stack the same "controller"
and "view" that Apple uses for making
calls and sending emails? Or am I
going to have to code this all myself
to look like their app?
Yes. MFMailComposeViewController for Mail, and [[UIApplication sharedApplication] openURL:[NSURL URLWithString:telephoneText]] for a Call
I want the user to come back to the
same page they were on when the email
or phone call was initiated. How can
I do that or is my app gone if I use
their controller and nib?
For Mail this can be accomplished with MFMailComposeViewController. It's not possible for a telephone Call.
Assuming it's possible to do either
of these things, can I put the email
address I want for a default in the
to: field of the email view and if so
how?
Yes.
You can look at the sample code https://developer.apple.com/iphone/library/samplecode/MailComposer/index.html or the tutorial http://blog.mugunthkumar.com/coding/iphone-tutorial-in-app-email
unfortunately if you make a phone call then the application is terminated. For email however, I believe there is a framework or something to do that, I think it's in the messaging API, but I'm not 100% sure as whenever I use email stuff I just do a mailto: url (which closes the app)
You can not make a phone call from within you application without exiting your app.
You can send an email inside your application using MFMailComposeViewController. Your application will remain at whatever view it was at when you present the Mail Compose View Controller view. You can set all of the normal fields in an email (subject, recipients, cc, bcc, body, ect...).

iPhone programming: Sending data from one iPhone to another?

I am new to iPhone development. I created an iPhone application, using which user can create a Business Card kind of UI in TableView. I want to know how can i send a Business Card(which i created programmatically) data into another iPhone via SMS? I want to know the technology which i should use to sending such thing from one iPhone to another via SMS or Email, i shouldn't use WiFi/Bonjour service which can send only upto nearest area.
thanks.
Calve/
SMS wasn't designed for this, and so it probably won't work like you're describing. Here's what I would do:
You have your BusinessCard object. Upload it to your servers and give it a unique identifier. This identifier is what should be sent to the other person, whereupon they can use the identifier to download the appropriate card.
If you wanted to be super cool about it, you could maybe construct a URL like: "card://12345678890", where 1234567890 is the identifier. You could then set your app up to respond to "card://" urls. Then send the card URL around via SMS. When a user taps on the link in their SMS app, it'll automatically open up your app (providing that they have it downloaded and installed, and that nothing else has registered "card://").
For additional awesomeness, you can allow people to create "shortcuts" to their identifier (like bit.ly), so they can send around "card://my-cool-business" instead of "card://1234567890".
You could encode your business card data as a base64-encoded custom URL, assuming it isn't too large. An example of doing this kind of URL-driven data exchange (which does not require uploading anything to a server) can be found here.
I doubt that you'll be able to encode enough information in the tiny size of an SMS message (unless you were just sending compressed text, no images), but this approach would work well with email.
Where MMS is available you can send a VCard formatted object attachment by that route. The receiving phone will detect the attachment format and allow you to manipulate it.
This will also work to non iPhone devices.