IOS Study Notes (14th)-call and text message

Source: Internet
Author: User

 

[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "tel: // 10010"]; // call

 

 

 

 

UIWebView * callWebview = [[UIWebView alloc] init]; NSURL * telURL = [NSURL URLWithString: @ "tel: 10010"]; [callWebview loadRequest: [NSURLRequest requestWithURL: telURL]; // remember to add it to the view [self. view addSubview: callWebview];



 

 

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://10010"]];

 

2. send text messages

 

[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "sms: // 10010"]; // send a text message

 

 

IOS4.0 added MFMessageComposeViewCont

 

 


Body: Text message content

 

Add protocol:

 

#import <MessageUI/MessageUI.h>@interface DemoViewController : UIViewController <MFMessageComposeViewControllerDelegate>@end


 

 

-(Void) showMessageView {if ([MFMessageComposeViewController canSendText]) {MFMessageComposeViewController * controller = [[MFMessageComposeViewController alloc] init]; // autorelease]; controller. recipients = [NSArray arrayWithObject: @ "10010"]; controller. body = @ "test text message"; controller. messageComposeDelegate = self; [self presentModalViewController: controller animated: YES]; [[[controller viewControllers] lastObject] navigationItem] setTitle: @ "test SMS"]; // modify the text message interface title} else {[self alertWithTitle: @ "prompt message" msg: @ "the device has no SMS function"] ;}}// MFMessageComposeViewControllerDelegate-(void) messageComposeViewController :( MFMessageComposeViewController *) controller didFinishWithResult :( MessageComposeResult) result {[controller failed: NO]; // The key sentence cannot be YES switch (result) {case when: [self alertWithTitle: @ "prompt message" msg: @ "cancel sending"]; break; case MessageComposeResultFailed: // send failed [self alertWithTitle: @ "prompt message" msg: @ "sent successfully"]; break; case MessageComposeResultSent: [self alertWithTitle: @ "prompt message" msg: @ "failed to send"]; break; default: break ;}} -(void) alertWithTitle :( NSString *) title msg :( NSString *) msg {UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message: msg delegate: self cancelButtonTitle: nil failed: @ "OK", nil]; [alert show];}



 

 

 


@ Zhang xingye TBOW

 

 

Refer:

Http://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMessageComposeViewController_class/Reference/Reference.html

 

 

Related Article

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.