[[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