IOS開發(fā),調(diào)用打電話,發(fā)短信,打開網(wǎng)址

調(diào)用 自帶mail

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@hzlzh.com"]];

調(diào)用 電話phone

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]];
iOS應用內(nèi)撥打電話結(jié)束后返回應用
一般在應用中撥打電話的方式是:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://123456789"]];
使用這種方式撥打電話時,當用戶結(jié)束通話后,iphone界面會停留在電話界面。

用如下方式,可以使得用戶結(jié)束通話后自動返回到應用:

UIWebView*callWebview =[[UIWebView alloc] init];
NSURL *telURL =[NSURL URLWithString:@"tel:10086"];// 貌似tel:// 或者 tel: 都行
[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
//記得添加到view上
[self.view addSubview:callWebview];
還有一種私有方法:(可能不能通過審核)
  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://10086"]];

調(diào)用 SMS

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];

調(diào)用自帶 瀏覽器 safari

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.hzlzh.com"]];
調(diào)用phone可以傳遞號碼,調(diào)用SMS 只能設(shè)定號碼,不能初始化SMS內(nèi)容。
若需要傳遞內(nèi)容可以做如下操作:

加入:

MessageUI.framework
#import <MessageUI/MFMessageComposeViewController.h>
實現(xiàn)代理:
MFMessageComposeViewControllerDelegate
調(diào)用sendSMS函數(shù)

//內(nèi)容,收件人列表

- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
{

MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];

if([MFMessageComposeViewController canSendText])

{

    controller.body = bodyOfMessage;  

    controller.recipients = recipients;

    controller.messageComposeDelegate = self;

    [self presentModalViewController:controller animated:YES];

}  

}
處理發(fā)送完的響應結(jié)果
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
  [self dismissModalViewControllerAnimated:YES];

  if (result == MessageComposeResultCancelled)
  NSLog(@"Message cancelled")
  else if (result == MessageComposeResultSent)
  NSLog(@"Message sent") 
  else
  NSLog(@"Message failed") 
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容