Imam Arief W
Imam Arief W

Reputation: 557

Dialing a number

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?

Upvotes: 0

Views: 400

Answers (2)

thyrgle
thyrgle

Reputation:

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.

Upvotes: 2

No one in particular
No one in particular

Reputation: 2672

Shouldn't that be:

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

??

Upvotes: 0

Related Questions