Mr. JZ Posted September 19, 2008 Share Posted September 19, 2008 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 More sharing options...
JSn1™ Posted September 20, 2008 Share Posted September 20, 2008 In the SDK, there is a call button in which you just have to set the phone number. You can locate it on library. Link to comment Share on other sites More sharing options...
Mr. JZ Posted September 22, 2008 Author Share Posted September 22, 2008 hi, could you please elaborate more on that. By the way which sdk version you are talking about, i have 2.0 thanks Link to comment Share on other sites More sharing options...
MoDs Posted September 29, 2008 Share Posted September 29, 2008 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 More sharing options...
Recommended Posts