9

I am trying to make a call from my app using

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://1800000002"]];

This is a toll free number in India.But while dialing, it is converting to +1(800)-000-000 (Converting and Saying dialing to United states number)

I have referred Copy/paste phone number into keypad And When I'm redialing a Toll free No. in India, iPhone is connecting USA]. But could not find the solution.

So can any please help me to avoid this ISD call Indian local call..

soumya
  • 3,801
  • 9
  • 35
  • 69

3 Answers3

2

The telprompt wants the number in the international format. So you need to convert it to that. I think for India and the number you are trying to call, this should be +911800000002.

So this should work:

NSURL *phoneURL = [NSURL URLWithString:@"telprompt://+911800000002"];
if ([[UIApplication sharedApplication] canOpenURL:phoneURL]) {
    [[UIApplication sharedApplication] openURL:phoneURL];
} else {
    // handle that case. e.g show number to user so that they can
    // type it in a phone manually or copy it to the clipboard and
    // notify user about that.
}

Depending on how the local numbers compared to international format works in India, you might need to remove the 1 on your number, not sure about that.

On a sidenote: You should always use the international format when dealing with phone numbers. Otherwise a device that is currently outside of the destination country may call somebody else or simply can't place the call at all.

Michael Ochs
  • 2,846
  • 3
  • 27
  • 33
  • With your answer ,My loop executes in "if" part in loop which again exhibits same issue – soumya May 12 '16 at 12:03
  • Did you try my comment with removing the 1? So use `+91800000002`? The problem you are having is not apple's API here, but that you need to know how the indian telephone numbering works according to international formats. – Michael Ochs May 13 '16 at 09:40
  • @ Michael Ochs, Yes I have tried this. but gave me message yes "This is not a valid number"..Only turn off the Dail assist only saved but that is manually function – soumya May 13 '16 at 10:46
  • @sujania can you dial the number like this in your iPhone manually? – Michael Ochs May 16 '16 at 07:03
  • For manual dialling , it is connecting to correct number without any format change – soumya May 16 '16 at 07:15
  • yes but you need to find the international number that works manually. (+91...). That's the number you need to put in there. I can't help you much with that as this is a local problem. In Germany our area codes all start with `0`, our international code is `+49` and when converting we skip the leading `0` of the area code. So e.g. local `0123456789` would be international `+49123456789`. Putting the latter in the `NSURL` works, no matter in which country the caller is in. – Michael Ochs May 16 '16 at 10:16
  • @sujania This might help as well: https://countrycode.org/india Seems like toll free numbers in international format need to start with `+91 080` in India. – Michael Ochs May 16 '16 at 10:19
  • @ Michael Ochs, thank you for the link , but the call is redirecting to wrong number without using 1 or invalid number with appending +91 – soumya May 16 '16 at 12:25
1

County code added (For India : +91)

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://+911800000002"]];

Generic way to find out country code

NSLocale *currentLocale = [NSLocale currentLocale];  // get the current locale.
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; // get country code, e.g. ES (Spain), FR (France), etc.
Sam92
  • 45
  • 4
  • thank you for post but Country code returns as "US" for me with your code which is supposed to ISO country code is: in and the above telprompt again redirects me to ISD number – soumya Jul 18 '16 at 05:38
  • Hi @Sujania you might be checking on simulator, because I checked it & on device it returns correct value ! – Sam92 Jul 20 '16 at 11:49
  • ,My requirement not to get the local country code , but to avoid calling toll free number as ISD when dial assist is on in user device phone settings. I am testing on iPhone5s Device only – soumya Jul 20 '16 at 12:18
0

Your app might get rejected by Apple if you use telprompt. Use the following code to dial a number programmatically and see that you are inputting the number you'd like to call with correct format.

NSString *phoneNumber = @"+1800000002;
NSString *phoneURLString = [NSString stringWithFormat:@"tel:%@", phoneNumber];
NSURL *phoneURL = [NSURL URLWithString:phoneURLString];
[[UIApplication sharedApplication] openURL:phoneURL];

source: Replacing tel or telprompt to call

Community
  • 1
  • 1
Glenn Posadas
  • 12,555
  • 6
  • 54
  • 95
  • this is giving same me error as I m getting currently . – soumya Apr 29 '16 at 12:50
  • 1
    If you want to be sure to get the Indian number, why not append +91? So `@"+911800000002"` – dirkgroten Apr 29 '16 at 13:05
  • @dirkgroten If i add +91 , than it is giving me massage as not a valid number – soumya Apr 29 '16 at 13:19
  • 1
    You app can be rejected if you doesn't check opening url so: if ([[UIApplication sharedApplication] canOpenURL:phoneURL]) {..open url } – Alex Kosyakov Apr 29 '16 at 13:47
  • @Sujania, I think this has to do "Dial Assist" feature. Go to Settings -> Phone -> Switch off Dial Assist and see if it now works with `@"1800000002"` (don't put a "+"). Unfortunately there's no way to tell whether your users have this option on or off. I would file a bug with Apple about this not being recognised properly by Dial Assist. – dirkgroten May 02 '16 at 09:14
  • @dirkgroten thank you..Yes only with this it is giving a valid dail call..but trying for same functionality when fail assist is enabled also...Hope as you said me, this may not be possible – soumya May 02 '16 at 09:26
  • This answer is incorrect. a) why should this get rejected? Using telprompt for years! b) specifying `+1` instead of `1...` makes the 1 the international code, which points to the USA. – Michael Ochs May 12 '16 at 07:38