Reputation: 2186
Is this is the only way to open a dialer to call or msg.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:+%@",phoneNumber]]];
if yes. then will this support from ios3 to ios6 (beta).
if no. then can any one please give some sample code.(if any private api can do this pls mention it)
if separate functions are available for sending sms and calling a number, please let me know that too.
in ipad 1 with ios 4.2.6, the following codes are not working
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"sms:9190432097420"]]];
and
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:9190432097420"]]]
Wr does the problem lies
Upvotes: 0
Views: 1517
Reputation: 4909
According to UIApplication
's Class Reference, the openUrl:
method is available in iOS 2.0 and later. So you should be safe to use that method.
With regard to your example, it's 'safer' if you first check if there is an application that can handle the provided url. For instance:
NSURL *url = [NSURL URLWithString:@"tel:9190432097420"];
if([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
else {
NSLog(@"No application for url '%@'", url);
}
Are you testing on an actual device or in the simulator? The simulator does not support this as far as I've seen.
Upvotes: 2