Iphone的发送短信-邮件-打电话代码示例
2012-01-31 18:21
435 查看
Maphttp://maps.google.com/maps?q=ShanghaiEmailmailto://myname@google.com Teltel://10086 Msgsms://10086
openURL的使用方法:
CODE:
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:appString]];
除此之外,还可以自己定义URL,方法如下:
CODE:
打开info.plist,添加一项URLtypes 展开URLtypes,再展开Item1,将Item1下的URLidentifier修改为URLScheme 展开URLScheme,将Item1的内容修改为myapp 其他程序可通过myapp://访问此自定义URL
+(
void
)alert:(NSString*)msg
{
UIAlertView*alertView=[[[UIAlertViewalloc]initWithTitle:msgmessage:@
""
delegate:selfcancelButtonTitle:@
"OK"
otherButtonTitles:nil,nil]autorelease];
[alertViewshowWithBackground];
}
+(NSString*)cleanPhoneNumber:(NSString*)phoneNumber
{
NSString*number=[NSStringstringWithString:phoneNumber];
NSString*number1=[[[numberstringByReplacingOccurrencesOfString:@
""
withString:@
""
]
//stringByReplacingOccurrencesOfString:@"-"withString:@""]
stringByReplacingOccurrencesOfString:@
"("
withString:@
""
]
stringByReplacingOccurrencesOfString:@
")"
withString:@
""
];
return
number1;
}
+(
void
)makeCall:(NSString*)phoneNumber
{
NSString*numberAfterClear=[selfcleanPhoneNumber:phoneNumber];
NSURL*phoneNumberURL=[NSURLURLWithString:[NSStringstringWithFormat:@
"tel:%@"
,numberAfterClear]];
NSLog(@
"makecall,URL=%@"
,phoneNumberURL);
[[UIApplicationsharedApplication]openURL:phoneNumberURL];
}
拔打前会有提示,并且拔打结束后返回到自己的应用程序
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:@"telprompt://10086"]];
直接拔打,不会提示,拔打结束后停留在电话应用上
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:@"tel://10086"]];
+(
void
)sendSms:(NSString*)phoneNumber
{
NSString*numberAfterClear=[selfcleanPhoneNumber:phoneNumber];
NSURL*phoneNumberURL=[NSURLURLWithString:[NSStringstringWithFormat:@
"sms:%@"
,numberAfterClear]];
NSLog(@
"sendsms,URL=%@"
,phoneNumberURL);
[[UIApplicationsharedApplication]openURL:phoneNumberURL];
}
+(
void
)sendEmail:(NSString*)phoneNumber
{
NSURL*phoneNumberURL=[NSURLURLWithString:[NSStringstringWithFormat:@
"mailto:%@"
,phoneNumber]];
NSLog(@
"sendsms,URL=%@"
,phoneNumberURL);
[[UIApplicationsharedApplication]openURL:phoneNumberURL];
}
+(
void
)sendEmail:(NSString*)tocc:(NSString*)ccsubject:(NSString*)subjectbody:(NSString*)body
{
NSString*str=[NSStringstringWithFormat:@
"mailto:%@?cc=%@&subject=%@&body=%@"
,
to,cc,subject,body];
str=[strstringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:str]];
}
相关文章推荐
- Iphone的发送短信-邮件-打电话代码示例(转)
- iphone 发送短信/邮件/打电话
- iphone 发送短信/邮件/打电话的源代码
- 【代码】Android: SMS TEL MAIL 发送短信、打电话、发送邮件使用集合
- 【iphone应用开发】iphone应用开发之十:发送短信/邮件/打电话
- 发送短信/邮件/打电话的代码
- spring 发送邮件代码示例(带附件和不带附件的)
- JAVA代码发送邮件示例和解释
- 发送短信/邮件/打电话 code(转)
- 使用spring mail发送html邮件的示例代码
- iOS开发中实现邮件和短信发送的简单示例
- 邮件发送代码示例
- Android发送接收短信的代码示例(本人验证OK)
- Android 后台发送邮件示例 (收集应用异常信息+Demo代码)
- C# 发送邮件示例代码(GMail和Exchange)
- php中socket方式发送邮件代码示例
- 发送短信/邮件/打电话:
- 发送邮件的代码示例
- java发送邮件 示例代码