iOS Three Ways to Dial Phone Code

  • 2021-07-10 20:59:54
  • OfStack

1. In this way, if you can't return to the original application after dialing, you will stay in the address book, and you will dial directly without popping up a prompt


NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"186xxxxxxxx"];
// NSLog(@"str======%@",str);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];

2. In this way, after calling, you will return to the original program and pop up a prompt. 1. Use this


NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"186xxxxxxxx"];
UIWebView * callWebview = [[UIWebView alloc] init];
[callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
[self.view addSubview:callWebview];

3. In this way, you will also go back to the original program (pay attention to telprompt here) and pop up a prompt


NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",@"186xxxxxxxx"];
// NSLog(@"str======%@",str);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]

Related articles: