1.調用系統(tǒng)撥號
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:電話號碼"]];
2.調用系統(tǒng)短信
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://電話號碼"]];
2.1.如果要設置默認的短信內容
這個設置默認短信的時候,是在你的APP中會跳轉出一個短信的編輯界面的诵,仍然在自己APP的界面里面,并非跳轉到系統(tǒng)的短信界面
同時這個默認的內容用戶是可以修改過后在發(fā)送的佑钾,相當于編輯狀態(tài)
// 導入頭文件
#import <MessageUI/MFMessageComposeViewController.h>
// 添加代理
MFMessageComposeViewControllerDelegate
- (void)sendSMS{
MFMessageComposeViewController *messageViewController = [[MFMessageComposeViewController alloc] init];
messageViewController.messageComposeDelegate = self;
if ([MFMessageComposeViewController canSendText]) {//判斷能否發(fā)送短信
messageViewController.recipients = @[@"手機號碼1",@"手機號碼2"]; // 添加收件人號碼西疤,可以添加多個
messageViewController.body = @"要發(fā)送的短信內容"; // 要發(fā)送的內容
[self presentViewController:messageViewController animated:YES completion:nil];
}
}
#pragma mark - MFMessageComposeViewControllerDelegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{
//可以判斷短信發(fā)送的結果
if (result == MessageComposeResultCancelled) {
NSLog(@"短信被取消");
}else if (result == MessageComposeResultSent) {
NSLog(@"短信發(fā)送成功");
}else if (result == MessageComposeResultFailed) {
NSLog(@"短信發(fā)送失敗");
}
}
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(@"郵件發(fā)送成功");
}else if (result == MessageComposeResultFailed) {
NSLog(@"郵件發(fā)送失敗");
}
}
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]];