關於iOS應用撥打電話, 我所知道的有3種辦法, 具體如下:
特點: 直接撥打, 不彈出提示。 並且, 撥打完以後, 留在通訊錄中, 不返回到原來的應用。
//撥打電話
- (void)callPhone:(NSString *)phoneNumber
{
//phoneNumber = "18369......"
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phoneNumber];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}特點: 撥打前彈出提示。 並且, 撥打完以後會回到原來的應用。
//撥打電話
- (void)callPhone:(NSString *)phoneNumber
{
//phoneNumber = "18369......"
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phoneNumber];
UIWebView * callWebview = [[UIWebView alloc] init];
[callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
[self.view addSubview:callWebview];
}特點: 撥打前彈出提示。 並且, 撥打完以後會回到原來的應用。
注意: Apple的官方文檔中, 沒有出現過telprompt, 之前也有人使用這個, 上傳審核的時候被拒絕了。
//撥打電話
- (void)callPhone:(NSString *)phoneNumber
{
//phoneNumber = "18369......"
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",phoneNumber];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}