打电话、发短信、发邮件常用代码
2016-01-08 15:14
288 查看
打电话、发短信、发邮件常用代码
+ (void) makeCall:(NSString *)phoneNumber{
if ([DeviceDetection isIPodTouch]){
[UIUtils alert:kCallNotSupportOnIPod];
return;
}
NSString* numberAfterClear = [UIUtils cleanPhoneNumber:phoneNumber];
NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", numberAfterClear]];
NSLog(@"make call, URL=%@", phoneNumberURL);
[[UIApplication sharedApplication] openURL:phoneNumberURL];
}
+ (void) sendSms:(NSString *)phoneNumber
{
if ([DeviceDetection isIPodTouch]){
[UIUtils alert:kSmsNotSupportOnIPod];
return;
}
NSString* numberAfterClear = [UIUtils cleanPhoneNumber:phoneNumber];
NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"sms:%@", numberAfterClear]];
NSLog(@"send sms, URL=%@", phoneNumberURL);
[[UIApplication sharedApplication] openURL:phoneNumberURL];
}
+ (void) sendEmail:(NSString *)phoneNumber
{
NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@", phoneNumber]];
NSLog(@"send sms, URL=%@", phoneNumberURL);
[[UIApplication sharedApplication] openURL:phoneNumberURL];
}
+ (void) sendEmail:(NSString *)to cc:(NSString*)cc subject:(NSString*)subject body:(NSString*)body
{
NSString* str = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=%@&body=%@",
to, cc, subject, body];
str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}
相关文章推荐
- C#设计模式前奏-面向对象设计原则
- Eclipse Java注释模板设置详解
- 用C语言实现对bmp格式图片打码(附源码)
- 从头认识java-17.2 基本的线程机制(2)-Executors的使用
- ubuntu14.04下的c/c++开发IDE环境
- C# 定时器计划任务
- 表格完全代码
- 如何处理Python3.4 使用pymssql 乱码问题
- Python的getattr(),setattr(),delattr(),hasattr()
- SpringMvc 开发配置流程
- C#运用存储过程新增一条记录并返回自动生成的ID
- smarty基础指南
- Python之数据聚合与分组运算
- Ruby on rails 连接mysql数据库实践
- Python之数据聚合与分组运算
- PHP webservice
- C++primer原书中的一个错误(派生类using声明对基类权限的影响)
- STM8S学习05——EEPROM读写操作C语言程序
- C#--静态字段
- Struts2的零配置和REST插件