iOS 调用系统发短信以及打电话功能
来源:互联网 发布:盟军敢死队2 for mac 编辑:程序博客网 时间:2024/05/29 04:03
调用打电话功能
[[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]];
调用发短信功能
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"sms://10000"]];
上面的发短信的功能是调用系统的界面,下面是实现一种点击按键就直接发送短信,相当于后台发送,能不能上软件商店,还不能确定。相对建议来说,尽量使用第一种。
首先导入MFMessageComposeViewControllerDelegate这个代理,实现里面的方法
-(void)messageComposeViewController:(MFMessageComposeViewController *)controllerdidFinishWithResult:(MessageComposeResult)result {
//Notifies users about errors associated with the interface
switch (result) {
case MessageComposeResultCancelled:
if (DEBUG) NSLog(@"Result: canceled");
break;
case MessageComposeResultSent:
if (DEBUG) NSLog(@"Result: Sent");
break;
case MessageComposeResultFailed:
if (DEBUG) NSLog(@"Result: Failed");
break;
default:
break;
}
[self dismissModalViewControllerAnimated:YES];
}
群发短信:
- (IBAction)sendSMS {
BOOL canSendSMS = [MFMessageComposeViewController canSendText];
NSLog(@"can send SMS [%d]",canSendSMS);
if (canSendSMS) {
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.navigationBar.tintColor = [UIColor blackColor];
picker.body = @"test";
picker.recipients = [NSArray arrayWithObject:@"10086"];
[self presentModalViewController:picker animated:YES];
[picker release];
}
}
给一个人发短信:从网页上获得内容
-(void)displaySMSComposerSheet
{
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
UIWebView *web = nil;
NSMutableString* absUrl = [[NSMutableString alloc] initWithString:web.request.URL.absoluteString];
[absUrl replaceOccurrencesOfString:@"http://i.aizheke.com" withString:@"http://m.aizheke.com"options:NSCaseInsensitiveSearch range:NSMakeRange(0, [absUrl length])];
picker.body=[NSString stringWithFormat:@"我在爱折客上看到:%@ 可能对你有用,推荐给你!link:%@",[webstringByEvaluatingJavaScriptFromString:@"document.title"],absUrl];
[absUrl release];
[self presentModalViewController:picker animated:YES];
[picker release];
}
事件绑定发送短信
-(IBAction)showSMSPicker:(id)sender {
Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
if (messageClass != nil) {
if ([messageClass canSendText]) {
[self displaySMSComposerSheet];
}
else {
//设备没有短信功能
}
}
else {
// iOS版本过低,iOS4.0以上才支持程序内发送短信
}
}
以上内容有一部分是来各个网站,本人自己加上自己的理解,整理,至于来源于互联网的那一部分作者是谁,来自于哪里,我现在也不知道了,写出来供大家学习。如果有你是那一部分的作者,请联系我!- iOS 调用系统发短信以及打电话功能
- ios 调用系统发短信以及打电话功能
- ios 调用系统发短信以及打电话功能
- iOS 调用系统发短信以及打电话功能
- iOS 调用系统发短信以及打电话功能
- iOS 调用系统发短信以及打电话功能
- iOS 调用系统发短信以及打电话功能
- iOS 调用系统发短信以及打电话功能
- iOS开发 调用系统发短信 打电话 功能
- ios 调用打电话,发短信的功能
- 调用系统打电话,发短信功能
- iOS开发之调用系统打电话发短信接口以及程序内发短信
- iOS开发之调用系统打电话发短信接口以及程序内发短信
- ios-王云鹤 调用ios系统功能---------------打电话、发短信、发邮件
- iOS应用调用系统打电话、发短信和发邮件功能
- iOS应用调用系统打电话、发短信和发邮件功能
- ios 调用系统功能打电话、发信息
- iOS打电话、发短信功能
- Ext初级学习-Windows
- javaBean
- java中的向上转型和向下转型
- Mapreduce程序中的FileInputFormat.addInputPaths和FileInputFormat.addInputPath方法
- CSS温故知新
- iOS 调用系统发短信以及打电话功能
- 连接打印机提示:找不到驱动程序,windows在网络上找不到Canon LBP2900的驱动程序,若要手动查找,请单击“确定”。否则,请单击“取消”并咨询你的网络管理员或者访问打印机制造商的网站
- 1034. Head of a Gang (30)
- hdu/hdoj 1075 FatMouse and Cheese
- JAVA设计模式-组合模式-Composite
- FD_WRITE解释
- oracle开发so easy(一)
- Mybatis使用及原理解析
- java中 Map 遍历方法