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