how can i send sms programmatically in iphone - 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

Related

MFMessageComposeViewController: How to restrict to send message as Cellular Message not as iMessage

I use MFMesageComposeViewController to send message it is creating problems for me.
when i send message to multiple recipients it works fine whether iMessages are Enable or disable from settings. But when i send message to single contact and and iMessages are enable from settings it gives me "Delivery failed" in Message App and show it as iMessage.
How can i force MFMessageComposeViewController to send it as Cellular Message.
My Code is:
[[[MFMessageComposeViewController alloc] init] autorelease];
if ([MFMessageComposeViewController canSendText]) {
controller.body = #"Sample Text Message";
controller.recipients = [NSArray arrayWithObject:#"XXXXXXXXXXXX"];
controller.messageComposeDelegate = self;
}
In short - you can't. If iMessage is enabled on a device and recipient is available as iMessage client, the message WILL be sent as iMessage. This behaviour is defined by iOS itself, you can't change it.
Apple does not provide any methods to detect whether a message is sent as 'iMessage' or 'SMS'.
Also,your message will not be send as iMessage if you are not connected to internet.If you have slow internet connect connectivity,your message will autometically be send as SMS.
If recipient is available as iMessage client and iMessage is enabled on your device then your message will be sent as iMessage. And if at that time,you are not connected to internet,then the 'send' button will be autometically disabled.

ios UIActivityViewController not attaching images sending text messages

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).

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.

how to check device is not able to send SMS

I wanted to know is it possible to check that a device can send sms or not.. if my app is installed on the ipad the sms button should hide... how to do this?
try this -
if([MFMessageComposeViewController canSendText])
{
// send sms
}
BOOL canSend = [MFMessageComposeViewController canSendText];
You can try checking for UIDeviceSMSCapability in UI Device extension categories from Erica Sadun.

Multiple recipients using SMS URL on iPhone

Is there a way to use the SMS URL to open the SMS app with multiple recipients? I've tried similar approaches to the mailto: protocol but it's not playing nice.
Starting with iOS 4.x you can include multiple recipients as shown below:
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
controller.recipients = [NSArray arrayWithObjects:#"1-222-333-4444", #"1-222-333-5555", nil];
As you probably noticed, the documentation does not mention any support for multiple recipients, so I think the answer is currently "No".
You could file an enhancement request here.