Reputation: 3049
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!
Upvotes: 0
Views: 558
Reputation: 183
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]];
Upvotes: 0
Reputation: 407
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
Upvotes: 2
Reputation: 69499
The tel:
URL schema is used incorrectly in your code, remove the //
NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", escapedPhoneNumber]];
Upvotes: 1