views:

77

answers:

2

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?

A: 

Shouldn't that be:

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

??

No one in particular
Both work fine, iirc.
dc
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
+1  A: 

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.

thyrgle
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
@Imam: if you have further questions, you should put a new question on Stack OVerflow.
Felixyz