Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

code.warrior

macrumors newbie
Original poster
Feb 6, 2009
14
0
Hi,

This might be a very simple thing for iPhone development purpose, but, sadly, though, I haven't been able to properly figure out how to programmatically dial a phone number and invoke the emailing phone applications, from my native application!

I've tried using the Apple URL schemes, in this regard, but it didn't help me much.
For dialing a number I'm using the following code:
Code:
NSString *callToURLString = [NSString stringWithFormat:@"tel:%@", [(UIButton*)sender currentTitle]];
if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:callToURLString]])
	{
		// there was an error trying to open the URL. We'll ignore for the time being.
	
	}
where currentTitle is the telephone number I want my application to dial. But all its doing is throw an alert:
Unsupported URL. The URL wasn't loaded: tel:9xx-xxx-xxxx
I've even tried tel://<tel. number> instead of tel:<tel. number> thinking that the scheme might have changed after iPhone OS 2.0 release, but to no avail.
The same is with the email app, invocation. I'm using the the following code for that purpose:
Code:
NSString *emailIDString = [NSString stringWithFormat:@"mailto:%@", [(UIButton*)sender currentTitle]];
	if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:emailIDString]])
	{
		// there was an error trying to open the URL.
                //for the time being we'll ignore it.
	}
where again currentTitle is the email id I want my application to mail to. Its throwing me the same alert. I've even tried mailto://<email-id>, with no success.
I'm referring to the following the documentation in this regard:
https://developer.apple.com/iphone/...eURLScheme_Reference/Articles/PhoneLinks.html

What am I doing wrong over there? Kindly enlighten me.


Thanks for reading through.
 

code.warrior

macrumors newbie
Original poster
Feb 6, 2009
14
0
Just to check; you're doing this on the device and not in the simulator, right?

oh, my bad, I just got to know that, it doesn't work on simulator.
Oh well, but I was wondering if there is any way, to do this on simulator? or is that, these phone functionalities ain't present on simulator itself?
 

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
Not to my knowledge. The simulator doesn't have the Phone or Mail apps so can't support either of those URL schemes. You ought to test on a device before submission anyway, since there are differences in behavior and limitations between the two.
 

code.warrior

macrumors newbie
Original poster
Feb 6, 2009
14
0
Not to my knowledge. The simulator doesn't have the Phone or Mail apps so can't support either of those URL schemes. You ought to test on a device before submission anyway, since there are differences in behavior and limitations between the two.

Yeah, thats alright. I was wondering whether we can test the features first on the simulator and then test it on the actual device. That would have been bit better, since my application is under development and this requirement is just one feature, along with several others which will be required to complete before testing it on actual device.

anyways, Thanks alot for the information, appreciate it.
 

priyank.ranka

macrumors member
Jun 11, 2008
51
0
I have include the message framework in my application but whn install on the phone whn trigger the mailto option it does not work.. is some thing we have to install on the phone for making it work
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.