1.调用系统拨号
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:电话号码"]];
2.调用系统短信
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://电话号码"]];
2.1.如果要设置默认的短信内容
这个设置默认短信的时候,是在你的APP中会跳转出一个短信的编辑界面,仍然在自己APP的界面里面,并非跳转到系统的短信界面
同时这个默认的内容用户是可以修改过后在发送的,相当于编辑状态
// 导入头文件
#import <MessageUI/MFMessageComposeViewController.h>
// 添加代理
MFMessageComposeViewControllerDelegate
- (void)sendSMS{
MFMessageComposeViewController *messageViewController = [[MFMessageComposeViewController alloc] init];
messageViewController.messageComposeDelegate = self;
if ([MFMessageComposeViewController canSendText]) {//判断能否发送短信
messageViewController.recipients = @[@"手机号码1",@"手机号码2"]; // 添加收件人号码,可以添加多个
messageViewController.body = @"要发送的短信内容"; // 要发送的内容
[self presentViewController:messageViewController animated:YES completion:nil];
}
}
#pragma mark - MFMessageComposeViewControllerDelegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{
//可以判断短信发送的结果
if (result == MessageComposeResultCancelled) {
NSLog(@"短信被取消");
}else if (result == MessageComposeResultSent) {
NSLog(@"短信发送成功");
}else if (result == MessageComposeResultFailed) {
NSLog(@"短信发送失败");
}
}
3.调用邮件
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"mailto://收件人邮箱"]];
3.1.设置默认的邮件内容
跟上面设置短信的默认内容一样
// 导入头文件
#import <MessageUI/MFMailComposeViewController.h>
// 添加代理
MFMailComposeViewControllerDelegate
- (void)sendMail{
MFMailComposeViewController * mcViewController = [[MFMailComposeViewController alloc] init];
mcViewController.mailComposeDelegate = self;
if ([MFMailComposeViewController canSendMail]) {
// 收件人
[mcViewController setToRecipients:@[@"邮箱地址1"]];
// 抄送
[mcViewController setCcRecipients:@[@"邮箱地址2",@"邮箱地址3"]];
// 密送
[mcViewController setBccRecipients:@[@"邮箱地址4"]];
// 主题
[mcViewController setSubject:@"邮件主题"];
// 内容
[mcViewController setMessageBody:@"邮件内容" isHTML:NO];
[self presentViewController:mcViewController animated:YES completion:nil];
}
}
#pragma mark - MFMailComposeViewControllerDelegate
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
if (result == MessageComposeResultCancelled) {
NSLog(@"邮件被取消");
}else if (result == MessageComposeResultSent) {
NSLog(@"邮件发送成功");
}else if (result == MessageComposeResultFailed) {
NSLog(@"邮件发送失败");
}
}
4.调用safari
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://网址"]];
5.调用APPStore界面
跳转到APPStore的下载界面的时候拥有两种情况,都是可以跳转的
5.1跳转到APPStore 官方下载界面
1).以itms-apps:
//或https://
开头的应用详情页链接,跳转到AppStore
//以itms-apps:为开头,拼接下载地址
NSString *url = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=%@",@"1014939463"];
//以https://为开头,拼接下载地址
NSString *url = [NSString stringWithFormat:@"https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=%@",@"1014939463"];
//跳转到appstore
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
2).以itms://
为开头的详情连接,虽然是跳转到 iTunes Store,但是打开的仍然是应用的下载页
//以itms://为头拼接下载地址
NSString *url = [NSString stringWithFormat:@"itms://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=%@",@"1014939463"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
6.跳转到应用评分页
此时以itms-apps://
和itms://
开头的链接都可以,而此时以https://
开头的链接不可以
NSString *url = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@",@"1014939463"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];