发送短信
-(void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = bodyOfMessage;
controller.recipients = recipients;
controller.messageComposeDelegate = self;
[self presentViewController:controller animated:YES completion:nil];
}else{
[OMGToast KMShowToast:@"该设备不支持短信功能"];
}
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissViewControllerAnimated:YES completion:nil];
if (result == MessageComposeResultCancelled)
{
NSLog(@"Message cancelled");
}
else if(result == MessageComposeResultSent)
{
NSLog(@"Message sent");
}
else
{
NSLog(@"Message failed");
}
}
或者直接
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://9016098909891"]]; //发短信
调用浏览器或者跳转APPStore
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]]; //调用safari打开网页
打电话
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://9016098909891"]]; // 打电话