ios UIActivityViewController not attaching images sending text messages - iphone

I'm using UIActivityViewController to share in Facebook,email,twitter and texting. Everything works just fine with the exception of texting. When I select the texting option it doens't attach the image to the text. Here is my code:
NSMutableArray *tmp=[[NSMutableArray alloc]init];
[tmp addObject:tmpImage];
[tmp addObject:#"Hello"];
NSArray *activityItems =[NSArray arrayWithArray:tmp];
UIActivityViewController *activityVC=[[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];
any of you knows why is not attaching the image to the texting part?
I'll really appreciate your help.

In app MMS (multi-media messaging) is not supported for the current iOS, only SMS is supported.
Possible solutions include:
•copying the image to the clipboard and having the user paste it into the messaging text box manually. (You can open a texting app that supports mms via the URI scheme "sms://" (just load that URL)
•loading the images into the eMail application and sending the eMail as a text message to either one of your servers that can sort out the issue, to the iMessages eMail address, or to the sms/mms eMail address (ex. a phone number of 404-345-6789 with AT&T could receive a text message if an eMail was sent to 4043456789#txt.att.net, all major carriers have an eMail address for every phone number).

Related

how to open iMessage with some text message?

This is how I open iMessage in my ipad app
NSString *stringURL = #"sms:";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
But what I want is open iMessage with some message i have text filed and i want to send its test to i message the way we do in mail like
[mailViewController setMessageBody:textView.text isHTML:NO];
is there anything in iMessage by which I can open iMessage with test filed Message
thanks in advance
Very late response, but this was the first result I saw when trying to solve this problem and I wanted to provide my solution.
My reason for wishing to open the iMessage app and not use MFMessageComposeViewController was because MFMessageComposeViewController does not support iMessage apps. My goal was to prompt the user to open my iMessage app and the only way to do that is to open the iMessage app.
This can be done as follows (in Swift 2):
let phoneNumber = "9765432100"
let bodyText = "Hello World"
guard let messageURL = NSURL(string: "sms:\(phoneNumber)&body=\(bodyText)") else { return }
if UIApplication.sharedApplication().canOpenURL(messageURL) {
UIApplication.sharedApplication().openURL(messageURL)
}
Some things to keep in mind:
1) You must add sms: to LSApplicationQueriesSchemes in your Info.plist
2) You can not open group messages in this manner.
3) Phone numbers must be formatted as follows: 9765432100. No spaces or extra characters, just the number
You can not open iMessage with any URL. Messages.app will detect if the number has iMessage support and sent the message via iMessage.
When calling sms: URI you are just opening any app that will handle it, on a iPhone/iPad this will be the message app. The is the given number has an iMessage account the sms will be send via the iMessage network. If no account is found on the iPad you can not send the message.
if you wan the user to send an SMS message from within your app you should use MFMessageComposeViewController.
Like:
// Fist check if we can send messages
if ([MFMessageComposeViewController canSendText] {
MFMessageComposeViewController *composer = [MFMessageComposeViewController new];
composer.body = #"Your message goes here";
// Then present the composer in a UIPopoverController.
}

How to keep my BCC in MFMailComposeViewController as readonly in iphone?

I am creating a project in which my app users can send mail within my app. While users sends each mail to their friends, i want that mail to send to my mail . so i added my mail in BCC. But the problem is user can easily delete my mail in BCC. I want my BCC to be not deletable .
I used the following code to send mail
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:#"4 Frax"];
[controller setMessageBody:#"Hai dude" isHTML:NO];
[controller setBccRecipients:[NSArray arrayWithObject:#"office#4Frax.com"]];
if (controller) [self presentModalViewController:controller animated:YES];
[controller release];
Can anyone please tell me how to avoid user from deleting my mail in BCC.
Thanks in advance.
You can't, there is no API available to do this. Since this is a privacy issue. Apple will not allow you to get the user e-mail (or let them mail you it) without expres permission from the user.
Thus the mail composer will not allow you adjust, hide and fields. You can only prefill it.
I'm not sure that's a nice way to treat your users... but if you really want to do it I think your only option is to set up your own mail server and route your message through that. As rckoenes notes, there is no API to do it on iOS.

Open mail client of iPhone programmatically

In my application, if the user gave their gmail account then i am required to open the mail client with the gmail login credentials which comes when we select gmail option of mail programmatically but if that account is already stored in mail then i am required to redirect the user directly to their account. Can anybody pliz give me a glimpse of how i can achieve this programmatically.
You won't get that much control over the Mail app as all apps on the iPhone are sandboxed to prevent them from messing with Apple applications.
The only thing you can do (if you want to open the mail client to send an email), is something like this:
/* create mail subject */
NSString *subject = [NSString stringWithFormat:#"Subject"];
/* define email address */
NSString *mail = [NSString stringWithFormat:#"test#test.com"];
/* define allowed character set */
NSCharacterSet *set = [NSCharacterSet URLHostAllowedCharacterSet];
/* create the URL */
NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat:#"mailto:?to=%#&subject=%#",
[mail stringByAddingPercentEncodingWithAllowedCharacters:set],
[subject stringByAddingPercentEncodingWithAllowedCharacters:set]]];
/* load the URL */
[[UIApplication sharedApplication] openURL:url];
/* release the URL. If you are using ARC, remove this line. */
[url release];
Swift version of Léon Rodenburg's answer:
// define email address
let address = "test#test.com"
// create mail subject
let subject = "Subject"
// create the URL
let url = NSURL(string: "mailto:?to=\(address)&subject=\(subject)".stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!)
// load the URL
UIApplication.sharedApplication().openURL(url!)
Swift:
if let url = NSURL(string: "mailto://\(email)") {
UIApplication.sharedApplication().openURL(url)
}
I would suggest a much more improved answer.
The Slack.com mobile app does this, it detects common email clients listed on the device and shows a popup picker of 'which' email client you would like to open.
So to implement:
Google around to find the top 10 email clients (eg Mail, Google Inbox, OutLook, AirMail etc).
Get a list of installed apps on the phone either by searching all apps (but I am told you can now only find if an app is explicitly installed, so you will need detect the app).
Show a popup list if more than 1 email app is detected, requesting them 'which' app to open eg. Mail, Inbox.
This is the best solution I have seen working to date.

iPhone MFMailComposeViewController

I have to send an email in one of the application,i have implement MFMailComposeViewController and everything is working fine, mail can be send and received also.
However my main issue is that, is it possible to send mail without opening the Sheet of MFMailComposeViewController ?
Means in my application I have to pass on url into suject field and have to type the recepients name in textfield, so is it that we cannot open the sheet of messagecontroller window and send the mail from the uibarbutton integration?
plz let me know that
If you dont want to use MFMailComposer, you may use following code.You have to handle you textfield's mail id's through string manipulation and append it in mString before body.you may use UItextview for body.
NSString *mString = #"mailto:foo#example.com?cc=bar#example.com&subject=Greetings%20from%20Cupertino!&body=Wish%20you%20were%20here!";
NSString *url = [NSString stringWithString:mString];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
To prevent spam from using the user mailbox, application cannot send mail automatically. THe user will have to press "Send" themselves. This way, they know what e-mail is going out.
If you want your app to automatically send mail, you will have to setup your own SMTP client/server.

how can i send sms programmatically in iphone

I need to send sms programmatically.
I found sending programmatically email in google,But did n't found clear info regarding sending sms programmatically.
Can any one pls post some sample code.
Thank u in advance.
You can prompt the user to send a message with the number to send it to filled out, along with the body of the message, but you cannot send an SMS without the user completing the send.
Here is a perfect blog that can be used to send sms through application. SMS sending through application is introduced with iOS4.0 So you can not use MFMessageComposer in the previous versions of iPhone.
iOS 4 will be the minimum requirement.
hAPPY iCODING...
-(void)displaySMSComposerSheet
{
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
NSString *str=#"Your String for SMS"
picker.body=str;
[self presentModalViewController:picker animated:YES];
[picker release];
}
Use this and add framework MessageUI.framework and call this function whenever you want to send message