0

I have got a requirement in my app which is that- On clicking a button we have to make dialing screen (calling screen) to appear as next view. Is this possible to do so? Please suggest me the way how can I do so?

Pawan Sharma
  • 3,199
  • 1
  • 25
  • 32

3 Answers3

2

It is not possible to open a dialing screen as a new view. You can only leave your program and open default iphone dialog screen as a new process (your application will be in the background in this moment). To do this use this code to dial number:

NSURL *phoneURL = [NSURL URLWithString:@"tel:12342333"];
[[UIApplication sharedApplication] openURL:phoneURL]]; 
edzio27
  • 4,126
  • 7
  • 33
  • 48
  • This won't work. You need to have `tel:` at the start of the URL. – rmaddy Nov 02 '12 at 20:02
  • Actually I want that screen to come on clicking a button which comes when we tap phone button in iPhone. I don't want to call just a single number. – Pawan Sharma Nov 02 '12 at 20:30
  • It's not possible, see this topic: http://stackoverflow.com/questions/419119/launch-an-app-from-within-another-iphone – edzio27 Nov 02 '12 at 20:41
0

For example in your action button block:

NSMutableString *phone = [[@"+ 12 34 567 89 01" mutableCopy] autorelease];
[phone replaceOccurrencesOfString:@" " 
                       withString:@"" 
                          options:NSLiteralSearch 
                            range:NSMakeRange(0, [phone length])];
[phone replaceOccurrencesOfString:@"(" 
                       withString:@"" 
                          options:NSLiteralSearch 
                            range:NSMakeRange(0, [phone length])];
[phone replaceOccurrencesOfString:@")" 
                       withString:@"" 
                          options:NSLiteralSearch 
                            range:NSMakeRange(0, [phone length])];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", phone]];
[[UIApplication sharedApplication] openURL:url];
Ulaş Sancak
  • 887
  • 7
  • 22
  • 1
    What's the point of all of that string manipulation on a string literal? You don't need to strip any of that out anyway. – rmaddy Nov 02 '12 at 20:04
  • @rmaddy Why? The string can contain "(,), white spaces" and etc. – Ulaş Sancak Nov 02 '12 at 20:27
  • Actually I want that screen to come on clicking a button which comes when we tap phone button in iPhone. I don't want to call just a single number. so please tell me is it possible and give solution for the same. – Pawan Sharma Nov 02 '12 at 20:29
  • @LegendReborn What do you mean? Please be more specific. – Ulaş Sancak Nov 02 '12 at 20:42
  • @UlasSancak You posted a literal string and then proceeded to replace characters that don't exist in it. Regardless, you don't need to strip those characters. You can create a `tel:` URL with spaces and parentheses. You just need to escape the URL properly like any other URL with certain characters in it. – rmaddy Nov 02 '12 at 21:25
  • I mean: When we tap on phone button provided in iPhone we get a screen in which we can dial a number and call on that number. I just want this functionality to come in my app's button click method. – Pawan Sharma Nov 02 '12 at 21:26
  • @rmaddy I know that but if the tel string coming from a database or etc which you cant sure what is inside of it, you should use strip... – Ulaş Sancak Nov 03 '12 at 17:02
0

For further reader of this question two app in iOS can interact the tutorial shows a demo how this can be done with the URL scheme in iOS.

Pawan Sharma
  • 3,199
  • 1
  • 25
  • 32