Jump to content

initiating a call on iphone


Mr. JZ
 Share

4 posts in this topic

Recommended Posts

Hi,

 

i am developing an application that needs to initiate a call, i am trying

 

self.number = @"18003998651";

 

UIApplication *app = [uIApplication sharedApplication]; NSString *num = [NSString stringWithFormat:@"tel://%@", self.number]; NSString *fixNum = [num stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSURL *url = [NSURL URLWithString:fixNum]; [app openURL:url];

 

i have also tried it with "tel:%@" instead of @"tel://%@"

 

 

but it shows alert : url unsupported, this url wasnt loaded

 

could you tell me what is the problem

 

 

Secondly how can i connect my xcode to my iphone device, so that application runs directly into iphone device

 

 

thanks,

Link to comment
Share on other sites

You can initiate a call like this:

 

-(NSString *)phoneNumberIdentifier:(NSString *)telephoneNumber
{
NSString *tempString = [[NSString stringWithFormat:@"%@%@", @"tel://", telephoneNumber] retain];
return tempString;
}

-(BOOL)callNumber:(NSString *)number
{
if (![number isEqualToString:@""])
	return FALSE;
else {
	[[UIApplication sharedApplication] openURL: [NSURL URLWithString:[self phoneNumberIdentifier:number]]];
}

return TRUE;
}

 

then just call

-(BOOL)callNumber:(NSString *)number

 

PS: This will work on the real device, but in the simulator, it won't. It's just a simulator, after all!

 

Pacon!

Link to comment
Share on other sites

 Share

×
×
  • Create New...