Help - Search - Members - Calendar
Full Version: initiating a call on iphone
InsanelyMac Forum > Apple World > Gadgets and Handheld Devices > iPhone
Mr. JZ
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,
JSn1™
In the SDK, there is a call button in which you just have to set the phone number.
You can locate it on library.
Mr. JZ
hi,

could you please elaborate more on that. By the way which sdk version you are talking about, i have 2.0

thanks


MoDs
You can initiate a call like this:

CODE
-(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
CODE
-(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!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.