Send SMS programmatically on iPhone? [duplicate] - iphone

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How to programmatically send SMS on the iPhone?
I want to send sms programmatically.
I tried with the following code,It triggers message composer and then user needs to manually select the send button but I just want everything to be done programmatically that is even to send sms not only insert recipent number and body message.
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
controller.body = #"Hello from Dinesh";
controller.recipients = [NSArray arrayWithObjects:#"999468*****", #"91999468****", nil];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
Help me...

Can't be done. The SDK does not allow automated SMSing, for obvious reasons—your app can ask the user to hit "Send", and that's really about it.

Here's an in App tutorial for sending SMS. Must have user consent, though, so may not be the answer you are looking for.
http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/

Related

How to send a message in iPhone devices?

Currently i am working in iPhone application, Using MFMessageComposeViewController to develop this application and its working fine.
But i want, message compose screen don't show on the screen, then the Message send programmatically ,
How to do this? it is possible? please help me
I tried this:
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
if([MFMessageComposeViewController canSendText])
{
controller.body = #"Hi";
controller.recipients = [NSArray arrayWithObjects:#"12345678", #"87654321", nil];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
I've tried to do this once but but it wont be accepted by app store. Apple wont let you send message/email without user knowledge about it.
You can use a sms:[target phone number] URL to open the SMS application, but there are no indications on how to prefill a SMS body with text (see this post on Apple Developer Forums).
You can't use the Message Framework to send a message without the user knowing about it. One common solution is to send the message details to a web service running on your server and send the message from the server. As long as you're not trying to be sneaky, I don't think there's anything wrong with doing that.

Sending sms from phonegap in iphone?

Is it possible to send sms using phonegap in iphone??If yes can anybody suggest me sample code or tutorials to do so???
Is it possible to find out user's phone number using phonegap in iphone??If yes can anybody suggest me sample code or tutorials to do so???
If you want to send sms via phone first you should create a plugin(see phonegap website to see how its done) then in plugin code(it should be native code do it like this :
You must add MessageUI.framework to your Xcode project and include a #import <MessageUI/MessageUI.h> in your header file.
Add these delegates to your header file MFMessageComposeViewControllerDelegate & UINavigationControllerDelegate.
In your IBAction method declare instance of MFMessageComposeViewController say messageInstance to check whether your device can send text use [MFMessageComposeViewController canSendText] in if condition, it'll return Yes/No in the if condition do these:
MFMessageComposeViewController *messageInstance = [[[MFMessageComposeViewController alloc] init] autorelease];
// set body for your messageInstance
messageInstance.body = #"Hello from Shah";
// then decide the recipients for the message as:
messageInstance.recipients = [NSArray arrayWithObjects:#"12345678", #"87654321", nil];
//Set a delegate to your messageInstance as:
messageInstance.messageComposeDelegate = self;
// Then present the messageViewController
[self messageInstance animated:YES];

MFMailComposeViewController in iphone app

hii every one
can we use " MFMailComposeViewController " with out using " presentModalViewController" , i mean i need to send email with out navigating to that mail composer page
i did a test project with following code
- (IBAction)buttonPressed {
arrRecipients = [[NSMutableArray alloc]init];
[arrRecipients addObject:#"xxxxxxx#gmail.com"];
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setSubject:#"Ravikiran test mail"];
[mailController setToRecipients:arrRecipients];
[mailController setMessageBody:#"this is my test app" isHTML:YES];
[self presentModalViewController:mailController animated:YES];
[mailController release];
}
it is sending mail but it is navigating to mail composer page & then its sending but i need to send mail just on click of the button
No, you cannot use MFMailComposeViewController to send an email without user interaction. There are probably 3rd parties libraries that let you do this, but the iOS SDK does not allow you to.
Also, you're leaking the arrRecipients array.
Best way for your needs is to have a web service which sends the data to an email id.
its always to good to inform the user in some way before sending the mail.
Thanks!

How to develop a SMS client for iOS?

my original title was How to customize TTMessageController for SMS transmission?. I changed this now because I look for any possible solution and not only those with TTMessageController.
Well, I am working on an simple application in xcode4. The user should be able to send SMS from different SMS gateways.
The background logic is quite simple because everything is managed by executing some http requests on an rest api.
The hard thing for me now is to setup the UI and that is where I need help because I am new to iOS development. This is how I want it to be:
http://img222.imageshack.us/img222/3159/bhrfe.png
There should be a recipient picker to either do autosearch on contacts or to directly pick a contact from the contact list. Beside I want only one recipient. And there should be a text area.
I also want to have a label somewhere at the bottom to show the current char number.
Since I did not find those UI elements in xcode4 library I searched for something similar and I found the TTMessageController which gives me the view you see in the picture.
However plus button does not work and I am not sure how to extend all this to do what I want.
I appreciate any idea on this.
For the + Button you can use the address book UI:
// This Code is taken from Apple's sample code QuickContacts
#import <AddressBookUI/AddressBookUI.h>
-(void)showPeoplePickerController {
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
// Display only a person's phone, email, and birthdate
NSArray *displayedItems = [NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonPhoneProperty]];
picker.displayedProperties = displayedItems;
// Show the picker
[self presentModalViewController:picker animated:YES];
[picker release];
}
The <ABPeoplePickerNavigationControllerDelegate> delegate include this methods:
– peoplePickerNavigationController:shouldContinueAfterSelectingPerson:
– peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:
– peoplePickerNavigationControllerDidCancel:
After selecting a person you can save his/her number in an array and in the text field (e.g. comma separated)
.
For the question if it will be approved here is the guideline:
https://developer.apple.com/appstore/resources/approval/guidelines.html
22.6 Apps that enable anonymous or prank phone calls or SMS/MMS messaging will be rejected
You can't use TTMessageController to send sms. The only possible way to send sms is to use MFMessageComposeViewController. Here's a tutorial on how to use it: http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/

Email body not displayed after sending from iPhone via code

I have couple of iPhone apps that sends an email via code.
I've noticed quite a number of emails coming in from customers where everything is populated except for the body message (i always see their signature though).
I sent a test message, using the same app from my iPhone device, and i get the message (a simple "this is a test" message).
Wondering if there are any coding that needs to occur to handle different version of iOS, or perhaps different iPhone device hardwares?
Anybody noticed this before?
I would consider the possibility that the users are accidentally pressing send on a blank email. Perhaps to eliminate this as a possibility, guard against blank messages in code, then if it still happens you'll know it's a real issue.
set all delegates properly
and use this
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
NSString *sub= [NSString stringWithFormat:#"The Black Sheep App: %# Specials",[[BarSplArr objectAtIndex:0]objectForKey:#"barname"]];
NSString *message=[NSString stringWithFormat:#"Check out these specials for %# on %#, %# \n\n %#",[[BarSplArr objectAtIndex:0]objectForKey:#"barname"],day,date,[[BarSplArr objectAtIndex:0]objectForKey:#"drinkspecials"] ];
[controller setSubject:sub];
[controller setMessageBody:message isHTML:NO];
[self presentModalViewController:controller animated:YES];
[controller release];