Is it possible to automatically send SMS's from an iPhone App other than the native text message app? - iphone

With the SDK / Cocoa Touch, is it feasible to make an app that will SMS automatically?
My objective isn't to SPAM anyone.

It is not possible, exactly for the reason you mentioned: it would make spamming possible.

You would need a server that would handle the SMS for you, and an API for the app to interact with that server. It's not possible to have your app send messages directly from the phone, but you can certainly have your app interact with an external service that will send the messages for you.

Three is a way to pre-build an SMS using MFMessageComposeViewController. The only issue with this method is that a modal view will be shown to the user to accept the SMS (like the window that sends an e-mail by the default way). There is no way to send a SMS in "silent mode" without jailbreak.
{
...
[self sendSMS:#"_SMS_TEXT_" recipientList:[NSArray arrayWithObjects:#"PHONE_NUMBER", nil]];
...
}
- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
{
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
if([MFMessageComposeViewController canSendText])
{
controller.body = bodyOfMessage;
controller.recipients = recipients;
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissModalViewControllerAnimated:YES];
if (result == MessageComposeResultCancelled)
NSLog(#"Message cancelled")
else if (result == MessageComposeResultSent)
NSLog(#"Message sent")
else
NSLog(#"Message failed")
}

Related

Obj C Modal box with options to call or email

Hi everyoneI need some direction on how to go about accomplishing a task. I have a app with 5 tab bar items I need to program one of the tabs to call a modal dialog box that has three options. 1. Cancel 2. Call Us 3. Email Us. if the user pushes call us the device should start calling our 800 number if they press email us then it should open the email client and put our sales or support team automatically in the "to:" section. Please provide me with some direction or perhaps a tutorial on how to something like this. Thank you for your help.
I have added these tasks in a different view using two UIButtons. if you come up with a way to do a popOver please let me know. If not I will go with what I have. Thank you. The code I used for email and call (both can be found by doing a SO search) in case anyone else looks in on this thread are as follows:
EMAIL
-(IBAction)emailUs:(id)sender
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailViewcontroller = [[MFMailComposeViewController alloc]init];
mailViewcontroller.mailComposeDelegate = self;
[mailViewcontroller setToRecipients:[NSArray arrayWithObjects:#"CustomerService#laserpros.com", nil]];
[mailViewcontroller setTitle:#"Email Us"];
[mailViewcontroller setSubject:#"Email Us"];
[mailViewcontroller setMessageBody:#"Your message goes here" isHTML:NO];
[self presentViewController:mailViewcontroller animated:YES completion:nil];
}
else
{
NSLog(#"Device is unable to send email in its current state.");
}
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
[self dismissViewControllerAnimated:YES completion:nil];
}
CALL
-(IBAction)callUs:(id)sender
{
NSURL *phoneNumber = [NSURL URLWithString:#"telprompt://18885585277"];
[[UIApplication sharedApplication] openURL:phoneNumber];
}

MFMessageComposeViewController stops sms messaging

I'm using MFMessageComposeViewController in my iOS app.
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText]){
controller.body = text;
controller.recipients = [NSArray arrayWithObjects:recipient,nil];
controller.messageComposeDelegate = self.navigationController;
[self.navigationController presentViewController:controller animated:YES];
}
-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
[self dismissModalViewControllerAnimated:YES];
}
Button "send message" is blue. If you send message not to the iMessage user, iPhone send sms not iMessage, but on some devices(iPhone 4, 5) operation fails. After that error you can't send messages to the user at all !!! using standard sms application in iPhone.
Deletion of contact, reboot, switching off iMessage doesn't solve this problem. MFMessageComposeViewController kills sms sending and we can't solve this issue.
We have iOS 6.1.3 version on out test devices.
try
controller.messageComposeDelegate = self;

Mail functionality iphone App Crashes

While Using email functionality in my App,the App is getting crash if we did'nt sign in at any email address.
Is there anyway to add the exception for this that users gets the Alertview without having App Crash?
What you can do is you can check whether device can send mail or not like below..
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
if ([MFMailComposeViewController canSendMail] == NO) {
//your alertview telling error
return;
}
else
{
//your code for sending mail
}
Happy Coding!#!!!

Cancel button on MFMessageComposeViewController does not show up

In my iPhone application, I have just implemented in-app SMS functionality. SMS functionality is working fine. But after opening MFMessageComposeViewController, if user wants to cancel sending sms, they have no option. The only option left is to send an sms, then only return on previous view. There should be a cancel button on navigation bar just as it is in the email composer. Below is the line of code that I wrote to have in-app sms functionality:
-(void) smsComposer{
MFMessageComposeViewController *_smsCompose = [[MFMessageComposeViewController alloc] init];
if ([MFMessageComposeViewController canSendText]) {
_smsCompose.body = #"SMS BODY";
_smsCompose.messageComposeDelegate = self;
[self presentModalViewController:_smsCompose animated:YES];
}
}
Is there anything that I am missing?
Thanks in advance,
PC
Try This....
in .h file
#import <MessageUI/MFMessageComposeViewController.h>
and
#interface TestViewController : UIViewController <MFMessageComposeViewControllerDelegate>
And then Button Click method
-(void)buttonPressed:(UIButton *)button
{
[self sendSMS:#"Body of SMS..." recipientList:[NSArray arrayWithObjects:#"+1-111-222-3333", #"111-333-4444", nil]];
}
MFMessageComposeViewController to create the SMS content and another method for handling the user interaction with the SMS dialog.
-(void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
{
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
if([MFMessageComposeViewController canSendText])
{
controller.body = bodyOfMessage;
controller.recipients = recipients;
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
}
And
-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissModalViewControllerAnimated:YES];
if (result == MessageComposeResultCancelled)
NSLog(#"Message cancelled")
else if (result == MessageComposeResultSent)
NSLog(#"Message sent")
else
NSLog(#"Message failed")
}
And remember: You cannot send SMS messages from within the simulator. Test on Device.

SMS option not working properly

I am using xcode 4.2 and i am developing an iphone APP , part of this app is sending SMSs
here is the code that I typed:
-(IBAction)SMSbutton{
MFMessageComposeViewController *sms = [[MFMessageComposeViewController alloc] init];
if ([MFMessageComposeViewController canSendText]) {
sms.body= [NSString stringWithFormat: #"text"];
sms.messageComposeDelegate = self;
[self presentModalViewController:sms animated:YES];
}
I can open the SMS application and send SMS but the problem is whether I click on the "cancel" or the "send" button the message application does not go away . how to do that ?
thanks
Set your calling class to be a delegate of the message composer, then catch the cancel and send events to dismiss the modal view controller as needed.
Set your header file to adhere to the MFMessageComposeViewControllerDelegate, and when you initialize the composer, set the message delegate to self:
MFMessageComposeViewController *george = [MFMessageComposeViewController alloc] init];
george.messageComposeDelegate = self;
Then implement the delegate method...easiest way is:
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissModalViewControllerAnimated:YES];
}
...but you can catch and deal with errors and events as necessary.
Implement messageComposeViewController:didFinishWithResult: in your delegate"
-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
if(result == MessageComposeResultCancelled) {
//Message cancelled
} else if(result == MessageComposeResultSent) {
//Message sent
}
[self dismissModalViewControllerAnimated:YES];
}
Have you tried dismissViewControllerAnimated:completion: or dismissModalViewControllerAnimated:?
[self dismissModalViewControllerAnimated: YES];