Funny
Funny

Reputation: 566

Send SMS without presenting MessageComposeViewController in iOS

I am working on sending SMS demo. I want to send how to send the SMS and how to set the delegate to MessageComposeViewController. and in order to send the message we have below line

[self presentViewController:messageController animated:NO completion:nil];

This line will present the MessageComposeView on screen with SEND button. And Once we click on send button it sends the message. What I want is to send the message directly without presenting this MessageController on screen. Please help how can I do this.

Upvotes: 1

Views: 3749

Answers (5)

Wasim K. Memon
Wasim K. Memon

Reputation: 6067

You can't do it without MFMessageComposeViewController. Apple won't allow to send SMS without user interaction.

As per document

You must not modify the view hierarchy presented by this view controller. You can, however, customize the appearance of the interface using the UIAppearance protocol.

I've alternate solution of this, Alternative way can be Using web service API. Create a web service at server side that send a message to specific number(s) that accept numbers as parameters with request.(according to your requirement)

As using Web server or external sms provider can do it.

Upvotes: 0

Glen Mandsberg
Glen Mandsberg

Reputation: 21

You could send the message using some webservice on the internet. http://client.suresms.com/ProjectInfo.aspx?Info=3 or www.clickatell.com. They have bunches of API for sending messages.

In SureSMS simply create an account and make a http request to http://suresms.com/Script/GlobalSendSMS.aspx?login=[youraccountnumber]&password=[yourpassword]&to=[phonenumber]&Text=Hallo.

Remember to URL encode the message text and use countrycodes. Thats it.

Upvotes: 1

Mohit Jethwa
Mohit Jethwa

Reputation: 633

You have to present MessageComposeViewController.It's not possible to send without presenting it.

MFMessageComposeViewController has delegate method while delete/send/save. which only perform while we present it.

  • (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error

Upvotes: 0

It is NOT possible . Apple willn't accept your App. Apple will reject your App if you do like that. Human interface guidelines should be followed up.

Upvotes: -1

Michael Dautermann
Michael Dautermann

Reputation: 89509

In this related question, Apple has restrictions in place on being able to send a SMS message without the user clicking the SEND button.

Apple really wants the user to be in control of the SMS functionality of their phone. Otherwise all sorts of data could be flying off some random app (e.g. spamming your contacts with "try this app out!", which would not be very friendly nor very nice).

One of the answers in this question does have a potential non-MFMessageComposeViewController solution, however I have a feeling that if Apple catches you doing this they might deny your app from being approved for the app store.

Upvotes: 2

Related Questions