打电话、发短信、发邮件常用代码
2015-07-06 14:48
302 查看
打电话、发短信、发邮件常用代码
+ (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]];
}
相关文章推荐
- spring中的constructor
- Picture Aspect Ratio
- spring中的constructor
- spring的SpEl表达式
- myeclipse修改servlet模板
- [PHP]Mysql的运用
- java的封装
- 解决Eclipse中SVN版本信息不显示的问题
- ZooKeeperEclipse 小工具
- FastDFS的配置、部署与API使用解读(3)以流的方式上传文件的客户端代码
- hdu 1533 Going Home
- maven 项目出现 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- C语言入门:03.关键字、标识符、注释
- FastDFS的配置、部署与API使用解读(2)以字节方式上传文件的客户端代码
- 【Github教程】史上最全github使用方法:github入门到精通
- 有了struts1为何还要学struts2
- Spring学习(7)--- @Required注解
- Thinkphp+easyui 简单分页
- java 生产者 消费者
- vim的python代码检测工具