0

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Irshad Mohamed
  • 2,129
  • 1
  • 18
  • 19

1 Answers1

2

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.

fguchelaar
  • 4,779
  • 23
  • 36
  • 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 – Irshad Mohamed Aug 27 '12 at 11:49
  • Are you testing in the simulator, or on an actual device? – fguchelaar Aug 27 '12 at 21:51
  • 1
    @IrshadMohamed if it's running 4.2.6, then of course it can't send an SMS, because the `Messages` app wasn't introduced until iOS 5, and it's an iPad, for god's sake, not an iPhone. – Richard J. Ross III Aug 27 '12 at 22:02
  • @RichardJ.RossIII - Thaks for ur comment. i too figured it later only. in case of iphone and 'tel:' is the only way to open dialer for ios versions right. – Irshad Mohamed Aug 28 '12 at 06:30