1. Send SMS
Header file
#import <MessageUI/MessageUI.h>
Head Agent
@interface Viewcontroller () <MFMessageComposeViewControllerDelegate>
Send Message
- (void) sendermessage{if([Mfmessagecomposeviewcontroller Cansendtext]) {///Instantiation of SMSMfmessagecomposeviewcontroller * MESSAGEVC =[[Mfmessagecomposeviewcontroller alloc] init]; ///target number, can be multipleMessagevc.recipients = @[@"18888888888",@"15555555555"]; MessageVc.navigationBar.tintColor=[Uicolor Redcolor]; Messagevc.body=@"What to send-what to send -what to send"; Messagevc.messagecomposedelegate=Self ; [Self PRESENTVIEWCONTROLLER:MESSAGEVC animated:yes completion:nil]; [[[[Messagevc Viewcontrollers] lastobject] navigationitem] Settitle:@"title"]; } Else{NSLog (@"The current device does not support SMS features"); } }
Proxy method implementation
-(void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *Controller Didfinishwithresult: (messagecomposeresult) Result {///Dismiss Mfmessagecomposeviewcontroller[Controller Dismissviewcontrolleranimated:yes Completion:nil]; if(Result = =messagecomposeresultsent) {NSLog (@"message sent successfully! "); } Else if(Result = =messagecomposeresultfailed) {NSLog (@"message sent failed! "); } Else if(Result = =messagecomposeresultcancelled) {NSLog (@"Click the Cancel"); } Else{ }}
2. Make a phone call
-(void) dialphone{ /// The method calls directly, does not eject the call (cancel) [[uiapplication Sharedapplication]openurl:[nsurl urlwithstring:@ "tel://18888888888"]; /// This method pops up whether to cancel the call Uiwebview*callwebview =[[UIWebView alloc] init]; *telurl =[nsurl urlwithstring:@ "tel:18888888888"]; [Callwebview loadrequest:[nsurlrequest Requestwithurl:telurl]; [Self.view Addsubview:callwebview];}
3. Send mail
-(void) senderemail{ *urlstr =@ "mailto:[email protected]?subject= Message subject (This parameter does not pass) &body= Mail content (this parameter is not transmitted)"; *url = [Nsurl urlwithstring:urlstr]; [[UIApplication sharedapplication] openurl:url];}
4. Send QQ message
-(void) senderqq{ //111111111111 for QQ number @ "mqq://im/chat ? chat_type=wpa&uin=111111111111&version=1&src_type=web"; [[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:url];}
ios-call, send text messages, e-mail "designated QQ users to send QQ message"