problem using tel: URL to initiate a callHow to use tel: with * (star, asterisk) or # (hash, pound) on iOS?adding uibutton to a detail view programmaticallyHow to debug a function(that can only work on a real device) with different SDK version?openUrl in landscape mode in iphoneCan I display a driving track between two points using the map kit?Can Iphone restore the state of app after [[UIApplication sharedApplication] openURL:[NSURL URLWithString:call_url]];Launching the iPhone maps application from your own codeiOS How to exit current app after using UIApplication openURL to launch a browserOpen map url in iPhone simulator always redirectshow to close the hyperlink window?Access the Apps available in iphoneWhere exactly to place “…[UIApplication sharedApplication] openURL…”?Open Url hosted using POST method in Safari using sharedApplication openURL method
Why do legislative committees exist?
What do mathematicians mean when they say some conjecture can’t be proven using the current technology?
What to look for in climbing shoes?
Why are road bikes (not time trial bikes) used in many triathlons?
Can a Resident Assistant Be Told to Ignore a Lawful Order?
Was Willow's first magic display (blazing arrow through arm) actual magic, and if not, what's the trick?
Is 7000 words too long for a chapter?
If I stood next to a piece of metal heated to a million degrees, but in a perfect vacuum, would I feel hot?
How to honestly answer questions from a girlfriend like "How did you find this place" without giving the impression I'm always talking about my exes?
What impact would a dragon the size of Asia have on the environment?
Why isn't aluminium involved in biological processes?
In Adventurers League, is there any way for an 5th-level wizard to gain heavy armor proficiency?
Ethical for a company to ask employees to move furniture on the weekend?
What are some symbols representing peasants/oppressed persons fighting back?
What's the meaning of こそ in this sentence?
Is dividends exclusively a part of earnings?
Why hasn't the U.S. government paid war reparations to any country it attacked?
Why is "dark" an adverb in this sentence?
Cauchy reals and Dedekind reals satisfy "the same mathematical theorems"
FPGA CPU's, how to find the max speed?
Why did Steve Rogers choose Sam in Endgame?
Is this more than a packing puzzle?
Why doesn't philosophy have higher standards for its arguments?
Confusion about a proof of a limit formula
problem using tel: URL to initiate a call
How to use tel: with * (star, asterisk) or # (hash, pound) on iOS?adding uibutton to a detail view programmaticallyHow to debug a function(that can only work on a real device) with different SDK version?openUrl in landscape mode in iphoneCan I display a driving track between two points using the map kit?Can Iphone restore the state of app after [[UIApplication sharedApplication] openURL:[NSURL URLWithString:call_url]];Launching the iPhone maps application from your own codeiOS How to exit current app after using UIApplication openURL to launch a browserOpen map url in iPhone simulator always redirectshow to close the hyperlink window?Access the Apps available in iphoneWhere exactly to place “…[UIApplication sharedApplication] openURL…”?Open Url hosted using POST method in Safari using sharedApplication openURL method
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to initiate a call from within an iPhone app.
This related code works and opens Safari as expected:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];
But, when I replace the http URL with a tel URL the resulting code does not invoke the phone app:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:3035551212"]];
No exceptions or alerts are generated (in the simulator or on a device).
Any idea what the problem might be with my invocation?
Thanks.
iphone
add a comment |
I'm trying to initiate a call from within an iPhone app.
This related code works and opens Safari as expected:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];
But, when I replace the http URL with a tel URL the resulting code does not invoke the phone app:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:3035551212"]];
No exceptions or alerts are generated (in the simulator or on a device).
Any idea what the problem might be with my invocation?
Thanks.
iphone
1
it should work, maybe there is something prior in the code. what is the device ? an ipod touch can't phone ...
– CiNN
May 1 '09 at 17:10
It's an iPhone.
– denton
May 1 '09 at 17:13
add a comment |
I'm trying to initiate a call from within an iPhone app.
This related code works and opens Safari as expected:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];
But, when I replace the http URL with a tel URL the resulting code does not invoke the phone app:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:3035551212"]];
No exceptions or alerts are generated (in the simulator or on a device).
Any idea what the problem might be with my invocation?
Thanks.
iphone
I'm trying to initiate a call from within an iPhone app.
This related code works and opens Safari as expected:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];
But, when I replace the http URL with a tel URL the resulting code does not invoke the phone app:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:3035551212"]];
No exceptions or alerts are generated (in the simulator or on a device).
Any idea what the problem might be with my invocation?
Thanks.
iphone
iphone
asked May 1 '09 at 17:00
dentondenton
2781 gold badge5 silver badges8 bronze badges
2781 gold badge5 silver badges8 bronze badges
1
it should work, maybe there is something prior in the code. what is the device ? an ipod touch can't phone ...
– CiNN
May 1 '09 at 17:10
It's an iPhone.
– denton
May 1 '09 at 17:13
add a comment |
1
it should work, maybe there is something prior in the code. what is the device ? an ipod touch can't phone ...
– CiNN
May 1 '09 at 17:10
It's an iPhone.
– denton
May 1 '09 at 17:13
1
1
it should work, maybe there is something prior in the code. what is the device ? an ipod touch can't phone ...
– CiNN
May 1 '09 at 17:10
it should work, maybe there is something prior in the code. what is the device ? an ipod touch can't phone ...
– CiNN
May 1 '09 at 17:10
It's an iPhone.
– denton
May 1 '09 at 17:13
It's an iPhone.
– denton
May 1 '09 at 17:13
add a comment |
11 Answers
11
active
oldest
votes
The iphone will dial a number using either of the formats listed below. But, it will do nothing if you are in the simulator. It took me 30 minutes of banging my head to figure this out.
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel://15415551234"]];
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel:15415551234"]];
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel:1-541-555-1234"]];
Link for Apple documentation on the tel: url scheme
Link for openURL documentation
2
The 1st format does not work on the device.
– joshis
Jun 29 '12 at 14:47
add a comment |
As @bentford said one might get miscarried because the simulator does show an alert when you try to click on a phone on the contacts app, this is just an alert that gets generated because the app checks whether or not the tel:
protocol is supported on the device or not.
Adding to what he writes you might want to also add support to escape any special characters or spaces as in:
NSString *phoneStr = [NSString stringWithFormat:@"tel:%@",[self.contactDetails objectForKey:@"phone"]];
NSString *escaped = [phoneStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:escaped]];
Hope it helps.
Cheers.
add a comment |
(
and )
are actually no problem if you use stringByAddingPercentEscapesUsingEncoding
as suggested by samiq. Same goes for +
, /
and spaces. It's a URL, so escaping seems natural.
If I'm guessing right, Apple's regular phone number recognition will be used in the tel:
scheme handler, if you escape correctly.
(missing reputation to make it a comment)
add a comment |
If your phone number has (
or )
in it, the Phone app will not launch.
FWIW, I've tried several alternatives including(xxx)-xxx-xxxx
and parenthesis doesn't seem to be a problem on iOS 7. Though blank spaces seems to hinder the Phone app from launching.
– Gabriel Osorio
Jul 30 '14 at 19:22
add a comment |
Haven't had any problems with it using tel:phone-number
and invoking it the same way you are. Only works on the iPhone device, though.
One thing I did have to do was strip out extraneous characters (like all parentheses, spaces, dashes and dots) out of the phone string. Some of the examples above (but not the original post) have dashes. That might be the problem.
Dashes are OK per the documentation: developer.apple.com/iphone/library/featuredarticles/…
– bentford
Oct 27 '09 at 5:24
add a comment |
I found that the issue was due to characters that where not allowed for tel:// URI - the following code solved my problem:
NSMutableCharacterSet *charSet = [NSMutableCharacterSet new];
[charSet formUnionWithCharacterSet:[NSCharacterSet whitespaceCharacterSet]];
[charSet formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]];
[charSet formUnionWithCharacterSet:[NSCharacterSet symbolCharacterSet]];
NSArray *arrayWithNumbers = [str componentsSeparatedByCharactersInSet:charSet];
NSString *numberStr = [arrayWithNumbers componentsJoinedByString:@""];
2
This code will also remove "+" character from the international country codes.
– Shmidt
Dec 5 '13 at 10:32
I prefer this answer for filtering questionable "phone number" strings. Thanks!
– quickthyme
Feb 2 '16 at 1:19
add a comment |
I just ran into this when trying to add a "Call" button to a UIAlertView
. I had the following code to handle the call:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
if (buttonIndex != 0)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:1-602-555-1212"]];
It wouldn't open anything, just like you. I even tried a regular http
URL. It turned out I had forgotten to set the delegate
to self
. That's probably your problem also.
add a comment |
some additional info about making phone calls via url scheme (as I think someone may find it useful)
How to use tel: with * (star, asterisk) or # (hash, pound) on iOs?
add a comment |
I got the same problem and at last I found the reason was that there was a space in the phone number (for better formatting). After removing the space it worked fine.
add a comment |
Here is an update on how to derive a phone number in 2018 (where iOS 11 and 12 are most common):
NSString *phoneNumberURLString = [@"tel://" stringByAppendingString:[result.phoneNumber
stringByAddingPercentEncodingWithAllowedCharacters:
[NSCharacterSet URLPathAllowedCharacterSet]]];
NSURL *phoneNumberURL = [NSURL URLWithString:phoneNumberURLString];
samiq's answer was what I used initially until I found that my app would crash due to a nil NSURL
being created (and later being passed into a collection object) due to failing to properly escape a phone number formatted like so: (###) ###-####
. The aforementioned code resolves this.
add a comment |
The URL should be tel://3035551212 and not tel:3035551212...
Add that // and it should work.
I tried that earlier without success. Thanks.
– denton
May 1 '09 at 18:11
1
Not true. Either works and Apple's documentation suggests the poster's version: developer.apple.com/iphone/library/featuredarticles/…
– bbrown
May 13 '09 at 2:22
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f812243%2fproblem-using-tel-url-to-initiate-a-call%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
11 Answers
11
active
oldest
votes
11 Answers
11
active
oldest
votes
active
oldest
votes
active
oldest
votes
The iphone will dial a number using either of the formats listed below. But, it will do nothing if you are in the simulator. It took me 30 minutes of banging my head to figure this out.
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel://15415551234"]];
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel:15415551234"]];
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel:1-541-555-1234"]];
Link for Apple documentation on the tel: url scheme
Link for openURL documentation
2
The 1st format does not work on the device.
– joshis
Jun 29 '12 at 14:47
add a comment |
The iphone will dial a number using either of the formats listed below. But, it will do nothing if you are in the simulator. It took me 30 minutes of banging my head to figure this out.
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel://15415551234"]];
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel:15415551234"]];
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel:1-541-555-1234"]];
Link for Apple documentation on the tel: url scheme
Link for openURL documentation
2
The 1st format does not work on the device.
– joshis
Jun 29 '12 at 14:47
add a comment |
The iphone will dial a number using either of the formats listed below. But, it will do nothing if you are in the simulator. It took me 30 minutes of banging my head to figure this out.
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel://15415551234"]];
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel:15415551234"]];
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel:1-541-555-1234"]];
Link for Apple documentation on the tel: url scheme
Link for openURL documentation
The iphone will dial a number using either of the formats listed below. But, it will do nothing if you are in the simulator. It took me 30 minutes of banging my head to figure this out.
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel://15415551234"]];
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel:15415551234"]];
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"tel:1-541-555-1234"]];
Link for Apple documentation on the tel: url scheme
Link for openURL documentation
edited Dec 19 '13 at 8:03
Yasmin Tiomkin
1492 silver badges14 bronze badges
1492 silver badges14 bronze badges
answered Oct 27 '09 at 5:20
bentfordbentford
17.5k6 gold badges53 silver badges56 bronze badges
17.5k6 gold badges53 silver badges56 bronze badges
2
The 1st format does not work on the device.
– joshis
Jun 29 '12 at 14:47
add a comment |
2
The 1st format does not work on the device.
– joshis
Jun 29 '12 at 14:47
2
2
The 1st format does not work on the device.
– joshis
Jun 29 '12 at 14:47
The 1st format does not work on the device.
– joshis
Jun 29 '12 at 14:47
add a comment |
As @bentford said one might get miscarried because the simulator does show an alert when you try to click on a phone on the contacts app, this is just an alert that gets generated because the app checks whether or not the tel:
protocol is supported on the device or not.
Adding to what he writes you might want to also add support to escape any special characters or spaces as in:
NSString *phoneStr = [NSString stringWithFormat:@"tel:%@",[self.contactDetails objectForKey:@"phone"]];
NSString *escaped = [phoneStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:escaped]];
Hope it helps.
Cheers.
add a comment |
As @bentford said one might get miscarried because the simulator does show an alert when you try to click on a phone on the contacts app, this is just an alert that gets generated because the app checks whether or not the tel:
protocol is supported on the device or not.
Adding to what he writes you might want to also add support to escape any special characters or spaces as in:
NSString *phoneStr = [NSString stringWithFormat:@"tel:%@",[self.contactDetails objectForKey:@"phone"]];
NSString *escaped = [phoneStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:escaped]];
Hope it helps.
Cheers.
add a comment |
As @bentford said one might get miscarried because the simulator does show an alert when you try to click on a phone on the contacts app, this is just an alert that gets generated because the app checks whether or not the tel:
protocol is supported on the device or not.
Adding to what he writes you might want to also add support to escape any special characters or spaces as in:
NSString *phoneStr = [NSString stringWithFormat:@"tel:%@",[self.contactDetails objectForKey:@"phone"]];
NSString *escaped = [phoneStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:escaped]];
Hope it helps.
Cheers.
As @bentford said one might get miscarried because the simulator does show an alert when you try to click on a phone on the contacts app, this is just an alert that gets generated because the app checks whether or not the tel:
protocol is supported on the device or not.
Adding to what he writes you might want to also add support to escape any special characters or spaces as in:
NSString *phoneStr = [NSString stringWithFormat:@"tel:%@",[self.contactDetails objectForKey:@"phone"]];
NSString *escaped = [phoneStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:escaped]];
Hope it helps.
Cheers.
edited Nov 12 '18 at 8:51
Stunner
8,19310 gold badges70 silver badges129 bronze badges
8,19310 gold badges70 silver badges129 bronze badges
answered Jul 21 '10 at 12:41
samiqsamiq
2,1441 gold badge23 silver badges26 bronze badges
2,1441 gold badge23 silver badges26 bronze badges
add a comment |
add a comment |
(
and )
are actually no problem if you use stringByAddingPercentEscapesUsingEncoding
as suggested by samiq. Same goes for +
, /
and spaces. It's a URL, so escaping seems natural.
If I'm guessing right, Apple's regular phone number recognition will be used in the tel:
scheme handler, if you escape correctly.
(missing reputation to make it a comment)
add a comment |
(
and )
are actually no problem if you use stringByAddingPercentEscapesUsingEncoding
as suggested by samiq. Same goes for +
, /
and spaces. It's a URL, so escaping seems natural.
If I'm guessing right, Apple's regular phone number recognition will be used in the tel:
scheme handler, if you escape correctly.
(missing reputation to make it a comment)
add a comment |
(
and )
are actually no problem if you use stringByAddingPercentEscapesUsingEncoding
as suggested by samiq. Same goes for +
, /
and spaces. It's a URL, so escaping seems natural.
If I'm guessing right, Apple's regular phone number recognition will be used in the tel:
scheme handler, if you escape correctly.
(missing reputation to make it a comment)
(
and )
are actually no problem if you use stringByAddingPercentEscapesUsingEncoding
as suggested by samiq. Same goes for +
, /
and spaces. It's a URL, so escaping seems natural.
If I'm guessing right, Apple's regular phone number recognition will be used in the tel:
scheme handler, if you escape correctly.
(missing reputation to make it a comment)
answered Jun 29 '11 at 21:26
SebastianSebastian
1,0861 gold badge13 silver badges13 bronze badges
1,0861 gold badge13 silver badges13 bronze badges
add a comment |
add a comment |
If your phone number has (
or )
in it, the Phone app will not launch.
FWIW, I've tried several alternatives including(xxx)-xxx-xxxx
and parenthesis doesn't seem to be a problem on iOS 7. Though blank spaces seems to hinder the Phone app from launching.
– Gabriel Osorio
Jul 30 '14 at 19:22
add a comment |
If your phone number has (
or )
in it, the Phone app will not launch.
FWIW, I've tried several alternatives including(xxx)-xxx-xxxx
and parenthesis doesn't seem to be a problem on iOS 7. Though blank spaces seems to hinder the Phone app from launching.
– Gabriel Osorio
Jul 30 '14 at 19:22
add a comment |
If your phone number has (
or )
in it, the Phone app will not launch.
If your phone number has (
or )
in it, the Phone app will not launch.
answered Dec 6 '10 at 7:38
WrightsCSWrightsCS
46.2k21 gold badges126 silver badges173 bronze badges
46.2k21 gold badges126 silver badges173 bronze badges
FWIW, I've tried several alternatives including(xxx)-xxx-xxxx
and parenthesis doesn't seem to be a problem on iOS 7. Though blank spaces seems to hinder the Phone app from launching.
– Gabriel Osorio
Jul 30 '14 at 19:22
add a comment |
FWIW, I've tried several alternatives including(xxx)-xxx-xxxx
and parenthesis doesn't seem to be a problem on iOS 7. Though blank spaces seems to hinder the Phone app from launching.
– Gabriel Osorio
Jul 30 '14 at 19:22
FWIW, I've tried several alternatives including
(xxx)-xxx-xxxx
and parenthesis doesn't seem to be a problem on iOS 7. Though blank spaces seems to hinder the Phone app from launching.– Gabriel Osorio
Jul 30 '14 at 19:22
FWIW, I've tried several alternatives including
(xxx)-xxx-xxxx
and parenthesis doesn't seem to be a problem on iOS 7. Though blank spaces seems to hinder the Phone app from launching.– Gabriel Osorio
Jul 30 '14 at 19:22
add a comment |
Haven't had any problems with it using tel:phone-number
and invoking it the same way you are. Only works on the iPhone device, though.
One thing I did have to do was strip out extraneous characters (like all parentheses, spaces, dashes and dots) out of the phone string. Some of the examples above (but not the original post) have dashes. That might be the problem.
Dashes are OK per the documentation: developer.apple.com/iphone/library/featuredarticles/…
– bentford
Oct 27 '09 at 5:24
add a comment |
Haven't had any problems with it using tel:phone-number
and invoking it the same way you are. Only works on the iPhone device, though.
One thing I did have to do was strip out extraneous characters (like all parentheses, spaces, dashes and dots) out of the phone string. Some of the examples above (but not the original post) have dashes. That might be the problem.
Dashes are OK per the documentation: developer.apple.com/iphone/library/featuredarticles/…
– bentford
Oct 27 '09 at 5:24
add a comment |
Haven't had any problems with it using tel:phone-number
and invoking it the same way you are. Only works on the iPhone device, though.
One thing I did have to do was strip out extraneous characters (like all parentheses, spaces, dashes and dots) out of the phone string. Some of the examples above (but not the original post) have dashes. That might be the problem.
Haven't had any problems with it using tel:phone-number
and invoking it the same way you are. Only works on the iPhone device, though.
One thing I did have to do was strip out extraneous characters (like all parentheses, spaces, dashes and dots) out of the phone string. Some of the examples above (but not the original post) have dashes. That might be the problem.
answered May 13 '09 at 4:34
RaminRamin
13k3 gold badges28 silver badges33 bronze badges
13k3 gold badges28 silver badges33 bronze badges
Dashes are OK per the documentation: developer.apple.com/iphone/library/featuredarticles/…
– bentford
Oct 27 '09 at 5:24
add a comment |
Dashes are OK per the documentation: developer.apple.com/iphone/library/featuredarticles/…
– bentford
Oct 27 '09 at 5:24
Dashes are OK per the documentation: developer.apple.com/iphone/library/featuredarticles/…
– bentford
Oct 27 '09 at 5:24
Dashes are OK per the documentation: developer.apple.com/iphone/library/featuredarticles/…
– bentford
Oct 27 '09 at 5:24
add a comment |
I found that the issue was due to characters that where not allowed for tel:// URI - the following code solved my problem:
NSMutableCharacterSet *charSet = [NSMutableCharacterSet new];
[charSet formUnionWithCharacterSet:[NSCharacterSet whitespaceCharacterSet]];
[charSet formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]];
[charSet formUnionWithCharacterSet:[NSCharacterSet symbolCharacterSet]];
NSArray *arrayWithNumbers = [str componentsSeparatedByCharactersInSet:charSet];
NSString *numberStr = [arrayWithNumbers componentsJoinedByString:@""];
2
This code will also remove "+" character from the international country codes.
– Shmidt
Dec 5 '13 at 10:32
I prefer this answer for filtering questionable "phone number" strings. Thanks!
– quickthyme
Feb 2 '16 at 1:19
add a comment |
I found that the issue was due to characters that where not allowed for tel:// URI - the following code solved my problem:
NSMutableCharacterSet *charSet = [NSMutableCharacterSet new];
[charSet formUnionWithCharacterSet:[NSCharacterSet whitespaceCharacterSet]];
[charSet formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]];
[charSet formUnionWithCharacterSet:[NSCharacterSet symbolCharacterSet]];
NSArray *arrayWithNumbers = [str componentsSeparatedByCharactersInSet:charSet];
NSString *numberStr = [arrayWithNumbers componentsJoinedByString:@""];
2
This code will also remove "+" character from the international country codes.
– Shmidt
Dec 5 '13 at 10:32
I prefer this answer for filtering questionable "phone number" strings. Thanks!
– quickthyme
Feb 2 '16 at 1:19
add a comment |
I found that the issue was due to characters that where not allowed for tel:// URI - the following code solved my problem:
NSMutableCharacterSet *charSet = [NSMutableCharacterSet new];
[charSet formUnionWithCharacterSet:[NSCharacterSet whitespaceCharacterSet]];
[charSet formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]];
[charSet formUnionWithCharacterSet:[NSCharacterSet symbolCharacterSet]];
NSArray *arrayWithNumbers = [str componentsSeparatedByCharactersInSet:charSet];
NSString *numberStr = [arrayWithNumbers componentsJoinedByString:@""];
I found that the issue was due to characters that where not allowed for tel:// URI - the following code solved my problem:
NSMutableCharacterSet *charSet = [NSMutableCharacterSet new];
[charSet formUnionWithCharacterSet:[NSCharacterSet whitespaceCharacterSet]];
[charSet formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]];
[charSet formUnionWithCharacterSet:[NSCharacterSet symbolCharacterSet]];
NSArray *arrayWithNumbers = [str componentsSeparatedByCharactersInSet:charSet];
NSString *numberStr = [arrayWithNumbers componentsJoinedByString:@""];
answered Jul 23 '11 at 14:18
Gil MargolinGil Margolin
1,42117 silver badges20 bronze badges
1,42117 silver badges20 bronze badges
2
This code will also remove "+" character from the international country codes.
– Shmidt
Dec 5 '13 at 10:32
I prefer this answer for filtering questionable "phone number" strings. Thanks!
– quickthyme
Feb 2 '16 at 1:19
add a comment |
2
This code will also remove "+" character from the international country codes.
– Shmidt
Dec 5 '13 at 10:32
I prefer this answer for filtering questionable "phone number" strings. Thanks!
– quickthyme
Feb 2 '16 at 1:19
2
2
This code will also remove "+" character from the international country codes.
– Shmidt
Dec 5 '13 at 10:32
This code will also remove "+" character from the international country codes.
– Shmidt
Dec 5 '13 at 10:32
I prefer this answer for filtering questionable "phone number" strings. Thanks!
– quickthyme
Feb 2 '16 at 1:19
I prefer this answer for filtering questionable "phone number" strings. Thanks!
– quickthyme
Feb 2 '16 at 1:19
add a comment |
I just ran into this when trying to add a "Call" button to a UIAlertView
. I had the following code to handle the call:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
if (buttonIndex != 0)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:1-602-555-1212"]];
It wouldn't open anything, just like you. I even tried a regular http
URL. It turned out I had forgotten to set the delegate
to self
. That's probably your problem also.
add a comment |
I just ran into this when trying to add a "Call" button to a UIAlertView
. I had the following code to handle the call:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
if (buttonIndex != 0)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:1-602-555-1212"]];
It wouldn't open anything, just like you. I even tried a regular http
URL. It turned out I had forgotten to set the delegate
to self
. That's probably your problem also.
add a comment |
I just ran into this when trying to add a "Call" button to a UIAlertView
. I had the following code to handle the call:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
if (buttonIndex != 0)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:1-602-555-1212"]];
It wouldn't open anything, just like you. I even tried a regular http
URL. It turned out I had forgotten to set the delegate
to self
. That's probably your problem also.
I just ran into this when trying to add a "Call" button to a UIAlertView
. I had the following code to handle the call:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
if (buttonIndex != 0)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:1-602-555-1212"]];
It wouldn't open anything, just like you. I even tried a regular http
URL. It turned out I had forgotten to set the delegate
to self
. That's probably your problem also.
answered May 13 '09 at 2:20
bbrownbbrown
5,5425 gold badges33 silver badges41 bronze badges
5,5425 gold badges33 silver badges41 bronze badges
add a comment |
add a comment |
some additional info about making phone calls via url scheme (as I think someone may find it useful)
How to use tel: with * (star, asterisk) or # (hash, pound) on iOs?
add a comment |
some additional info about making phone calls via url scheme (as I think someone may find it useful)
How to use tel: with * (star, asterisk) or # (hash, pound) on iOs?
add a comment |
some additional info about making phone calls via url scheme (as I think someone may find it useful)
How to use tel: with * (star, asterisk) or # (hash, pound) on iOs?
some additional info about making phone calls via url scheme (as I think someone may find it useful)
How to use tel: with * (star, asterisk) or # (hash, pound) on iOs?
edited May 23 '17 at 12:13
Community♦
11 silver badge
11 silver badge
answered Feb 23 '12 at 10:37
HlungHlung
9,7144 gold badges57 silver badges82 bronze badges
9,7144 gold badges57 silver badges82 bronze badges
add a comment |
add a comment |
I got the same problem and at last I found the reason was that there was a space in the phone number (for better formatting). After removing the space it worked fine.
add a comment |
I got the same problem and at last I found the reason was that there was a space in the phone number (for better formatting). After removing the space it worked fine.
add a comment |
I got the same problem and at last I found the reason was that there was a space in the phone number (for better formatting). After removing the space it worked fine.
I got the same problem and at last I found the reason was that there was a space in the phone number (for better formatting). After removing the space it worked fine.
edited Mar 26 at 7:32
Eugene Berdnikov
1,0242 gold badges10 silver badges21 bronze badges
1,0242 gold badges10 silver badges21 bronze badges
answered Feb 4 '11 at 11:41
boreasboreas
6581 gold badge12 silver badges25 bronze badges
6581 gold badge12 silver badges25 bronze badges
add a comment |
add a comment |
Here is an update on how to derive a phone number in 2018 (where iOS 11 and 12 are most common):
NSString *phoneNumberURLString = [@"tel://" stringByAppendingString:[result.phoneNumber
stringByAddingPercentEncodingWithAllowedCharacters:
[NSCharacterSet URLPathAllowedCharacterSet]]];
NSURL *phoneNumberURL = [NSURL URLWithString:phoneNumberURLString];
samiq's answer was what I used initially until I found that my app would crash due to a nil NSURL
being created (and later being passed into a collection object) due to failing to properly escape a phone number formatted like so: (###) ###-####
. The aforementioned code resolves this.
add a comment |
Here is an update on how to derive a phone number in 2018 (where iOS 11 and 12 are most common):
NSString *phoneNumberURLString = [@"tel://" stringByAppendingString:[result.phoneNumber
stringByAddingPercentEncodingWithAllowedCharacters:
[NSCharacterSet URLPathAllowedCharacterSet]]];
NSURL *phoneNumberURL = [NSURL URLWithString:phoneNumberURLString];
samiq's answer was what I used initially until I found that my app would crash due to a nil NSURL
being created (and later being passed into a collection object) due to failing to properly escape a phone number formatted like so: (###) ###-####
. The aforementioned code resolves this.
add a comment |
Here is an update on how to derive a phone number in 2018 (where iOS 11 and 12 are most common):
NSString *phoneNumberURLString = [@"tel://" stringByAppendingString:[result.phoneNumber
stringByAddingPercentEncodingWithAllowedCharacters:
[NSCharacterSet URLPathAllowedCharacterSet]]];
NSURL *phoneNumberURL = [NSURL URLWithString:phoneNumberURLString];
samiq's answer was what I used initially until I found that my app would crash due to a nil NSURL
being created (and later being passed into a collection object) due to failing to properly escape a phone number formatted like so: (###) ###-####
. The aforementioned code resolves this.
Here is an update on how to derive a phone number in 2018 (where iOS 11 and 12 are most common):
NSString *phoneNumberURLString = [@"tel://" stringByAppendingString:[result.phoneNumber
stringByAddingPercentEncodingWithAllowedCharacters:
[NSCharacterSet URLPathAllowedCharacterSet]]];
NSURL *phoneNumberURL = [NSURL URLWithString:phoneNumberURLString];
samiq's answer was what I used initially until I found that my app would crash due to a nil NSURL
being created (and later being passed into a collection object) due to failing to properly escape a phone number formatted like so: (###) ###-####
. The aforementioned code resolves this.
answered Nov 12 '18 at 8:56
StunnerStunner
8,19310 gold badges70 silver badges129 bronze badges
8,19310 gold badges70 silver badges129 bronze badges
add a comment |
add a comment |
The URL should be tel://3035551212 and not tel:3035551212...
Add that // and it should work.
I tried that earlier without success. Thanks.
– denton
May 1 '09 at 18:11
1
Not true. Either works and Apple's documentation suggests the poster's version: developer.apple.com/iphone/library/featuredarticles/…
– bbrown
May 13 '09 at 2:22
add a comment |
The URL should be tel://3035551212 and not tel:3035551212...
Add that // and it should work.
I tried that earlier without success. Thanks.
– denton
May 1 '09 at 18:11
1
Not true. Either works and Apple's documentation suggests the poster's version: developer.apple.com/iphone/library/featuredarticles/…
– bbrown
May 13 '09 at 2:22
add a comment |
The URL should be tel://3035551212 and not tel:3035551212...
Add that // and it should work.
The URL should be tel://3035551212 and not tel:3035551212...
Add that // and it should work.
answered May 1 '09 at 17:47
MugunthMugunth
11.6k14 gold badges60 silver badges92 bronze badges
11.6k14 gold badges60 silver badges92 bronze badges
I tried that earlier without success. Thanks.
– denton
May 1 '09 at 18:11
1
Not true. Either works and Apple's documentation suggests the poster's version: developer.apple.com/iphone/library/featuredarticles/…
– bbrown
May 13 '09 at 2:22
add a comment |
I tried that earlier without success. Thanks.
– denton
May 1 '09 at 18:11
1
Not true. Either works and Apple's documentation suggests the poster's version: developer.apple.com/iphone/library/featuredarticles/…
– bbrown
May 13 '09 at 2:22
I tried that earlier without success. Thanks.
– denton
May 1 '09 at 18:11
I tried that earlier without success. Thanks.
– denton
May 1 '09 at 18:11
1
1
Not true. Either works and Apple's documentation suggests the poster's version: developer.apple.com/iphone/library/featuredarticles/…
– bbrown
May 13 '09 at 2:22
Not true. Either works and Apple's documentation suggests the poster's version: developer.apple.com/iphone/library/featuredarticles/…
– bbrown
May 13 '09 at 2:22
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f812243%2fproblem-using-tel-url-to-initiate-a-call%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
it should work, maybe there is something prior in the code. what is the device ? an ipod touch can't phone ...
– CiNN
May 1 '09 at 17:10
It's an iPhone.
– denton
May 1 '09 at 17:13