iOS call to send SMS

Source: Internet
Author: User

Call :

The first: illegal use of private api,appstore

[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@"tel://10010" ]

The second type: UIWebView load phone, this is legal, can be on the App Store

Uiwebview*callwebview =[[uiwebview alloc] init];  Nsurl *telurl =[nsurl urlwithstring:@ "tel:10010"];  [Callwebview loadrequest:[nsurlrequest Requestwithurl:telurl];  Remember to add to the view  

Send message:

The first: Take advantage of the private API

[[UIApplication Sharedapplication]openurl:[nsurl urlwithstring:@"sms://10010"]];// texting

The second type: System-provided controller Mfmessagecomposeviewcontroller

1. The controller implements Mfmessagecomposeviewcontroller agent method Mfmessagecomposeviewcontrollerdelegate

@interface Demoviewcontroller:uiviewcontroller <MFMessageComposeViewControllerDelegate>    

2, call Mfmessagecomposeviewcontroller, and implement protocol mfmessagecomposeviewcontrollerdelegate.

-(void) Showmessageview {if ([Mfmessagecomposeviewcontroller Cansendtext]) {Mfmessagecomp Oseviewcontroller * Controller = [[Mfmessagecomposeviewcontroller alloc]init];                    Autorelease];               controller.recipients = [Nsarray arraywithobject:@ "10010"];                  Controller.body = @ "Test texting";            Controller.messagecomposedelegate = self;                    [Self Presentmodalviewcontroller:controller animated:yes]; [[[Controller viewcontrollers] lastobject] navigationitem] settitle:@ "Test SMS"];//Modify SMS Interface title}else{[s              Elf alertwithtitle:@ "hint message" msg:@ "Device no SMS function"]; }}-(void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *) controller didfinishwithresult: (MessageC Omposeresult) result{[Controller dismissmodalviewcontrolleranimated:no];//key sentence cannot be ' yes ' switch (re Sult) {case messagecomposeresultcancelled: [Self alertwithtitle:@ "prompt message" msg:@ "send Cancel"];          Break               Case messagecomposeresultfailed://send failed [self alertwithtitle:@ "prompt message" msg:@ "send Success"];          Break               Case messagecomposeresultsent: [Self alertwithtitle:@ "message" msg:@ "Send Failed"];          Break       Default:break; }}-(void) Alertwithtitle: (NSString *) title msg: (NSString *) msg {Uialertview *alert = [[Uialertview allo C] Initwithtitle:title message:msg delegate:self cancelbuttontitle:nil oth                                erbuttontitles:@ "OK", nil];                     [Alert show];   }

Reference: http://blog.csdn.net/xyz_lmn/article/details/8968209

iOS call to send SMS

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.