So i make an application that calls an number:
NSString *cleanedString = [[number componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789-+()"] invertedSet]] componentsJoinedByString:@""];
NSString *escapedPhoneNumber = [cleanedString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", escapedPhoneNumber]];
UIWebView *mCallWebview = [[UIWebView alloc] init] ;
[self.view addSubview:mCallWebview];
[mCallWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
However a tester with iPhone 5 reported that it's not working on his phone while on main works fine. He doesn't get any crashes or anything.
Thank u!
NSString *number = YOUR-NUMBER;
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",number]];
[[UIApplication sharedApplication] openURL:url];
Try with this code, it will navigate back to your app after finished call
tel:
URL模式在您的代码中使用不正确,请删除//
NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", escapedPhoneNumber]];
you can check this code.i hope this will help you.
NSString *phoneNo = @"your phone no";
NSString *strAppend = [@"tel:" stringByAppendingString:phoneNo];
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:strAppend]];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.