0

I read some reference about how to make a call programmatically on the iPhone, so I put this in my code :

UIApplication *app = [UIApplication sharedApplication];
NSString *urlString = [NSString stringWithFormat:@"tel:0225225657"];
NSURL *url = [NSURL URLWithString:urlString];
[app openURL:url];

is that correct? If yes, how can I know that my app has dialed that number while i run this in the simulator?

Felixyz
  • 19,053
  • 14
  • 65
  • 60
Imam Arief W
  • 557
  • 2
  • 6
  • 18

2 Answers2

2

Your code is working. You just can't use it in the simulator. My reasoning is this:

UIApplication *app = [UIApplication sharedApplication];
NSString *urlString = [NSString stringWithFormat:@"http://www.google.com"];
NSURL *url = [NSURL URLWithString:urlString];
[app openURL:url];

This is your code with but with http://www.google.com instead of your telphone URL. It opens Safari and goes to Google. Just test it on your device and it should work.

  • thanx guys, it works properly, nice solution.:) i've got one more question, when i dialing the number, is this automatically close my apps as same as when i connecting to google.?? – Imam Arief W Aug 25 '10 at 06:47
  • @Imam: if you have further questions, you should put a new question on Stack OVerflow. – Felixyz Aug 25 '10 at 07:05
0

Shouldn't that be:

NSString *urlString = [NSString stringWithFormat:@"tel://0225225657"];

??

No one in particular
  • 2,682
  • 2
  • 17
  • 20
  • i think that's no different between using // or no,, just because i use the simulator, so i can't see my apps dialing that number.. thnx for the answer guys.. :) – Imam Arief W Aug 25 '10 at 06:50