SMS for some small features commonly used in iOS

Source: Internet
Author: User

Method One

Jump directly to the text messaging interface, but cannot specify the text message content, and can not automatically return to the original application

Nsurl *url = [Nsurl urlwithstring:@ "sms://10010"];

[[UIApplication sharedapplication] openurl:url];



Method Two:

If you want to specify a text message, you have to use the MESSAGEUI framework


Include primary header file
#import <MessageUI/MessageUI.h>
Display the controller that sent the text message
Mfmessagecomposeviewcontroller *VC = [[Mfmessagecomposeviewcontroller alloc] init];
Set SMS Content
Vc.body = @ "Have you eaten yet?" ";
Set up a recipient list
vc.recipients = @[@ "10010", @ "02010010"];
Set up Proxy
Vc.messagecomposedelegate = self;


Display Controller
[Self PRESENTVIEWCONTROLLER:VC animated:yes completion:nil];


Proxy method, when the SMS interface is closed when the call, after the end will automatically return to the original application
-(void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *) controller didfinishwithresult: ( Messagecomposeresult) Result
{
Close the SMS interface
[Controller Dismissviewcontrolleranimated:yes Completion:nil];

if (result = = messagecomposeresultcancelled) {
NSLog (@ "Cancel send");
} else if (result = = Messagecomposeresultsent) {
NSLog (@ "already issued");
} else {
NSLog (@ "send failed");
}
}

SMS for some small features commonly used in iOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.