Phone Call Number with Hashtag on iOS

How to use tel: with * (star, asterisk) or # (hash, pound) on iOS?

This documentation from Apple should be helpful:

To prevent users from maliciously redirecting phone calls or changing the behavior of a phone or account, the Phone application
supports most, but not all, of the special characters in the tel
scheme. Specifically, if a URL contains the * or # characters, the
Phone application does not attempt to dial the corresponding phone
number.

UPDATE (Jan 2, 2018): The information mentioned here may be outdated. Please refer to new documentation if Apple has relaxed these rules in their newer SDKs. Refer to Husam's answer.

How to call (dialing) with * char in IOS?

The star may have to be encoded for use in a URL. Try %2A instead of *.

This replacement is not done by stringByAddingPercentEscapesUsingEncoding: since * is a valid URL character, albeit with a special meaning.

Call a GSM Service #123*

it is not possible to use gsm-codes with public methods

See Apples Documentation about Phone Links:

To prevent users from maliciously redirecting phone calls or changing the behavior of a phone or account, the Phone app supports most, but not all, of the special characters in the tel scheme. Specifically, if a URL contains the * or # characters, the Phone app does not attempt to dial the corresponding phone number.

Cannot make call to number with Objective-C

This is because your number contains * and #.

To prevent users from maliciously redirecting phone calls or changing
the behavior of a phone or account, the Phone application supports
most, but not all, of the special characters in the tel scheme.
Specifically, if a URL contains the * or # characters, the Phone
application does not attempt to dial the corresponding phone number.

If your application receives URL strings from the user or an unknown
source, you should also make sure that any special characters that
might not be appropriate in a URL are escaped properly. For native
applications, use the stringByAddingPercentEscapesUsingEncoding:
method of NSString to escape characters, which returns a properly
escaped version of your original string.

Please check iPhoneURLScheme for more details.

Double hashtag in openURL() crashes the app

The problem is that NSURL thinks that isn’t a valid URL. This:

NSURL(string: "tel//:1111111,,222##")

…returns nil. The problem isn’t the the escaping; it’s that NSURL apparently doesn’t accept anything with two # symbols in it. (Paste it into a playground to experiment for yourself.) It looks like it ought to, so you might file that as a bug with Apple. However, note this from Apple:

To prevent users from maliciously redirecting phone calls or changing the behavior of a phone or account, the Phone app supports most, but not all, of the special characters in the tel scheme. Specifically, if a URL contains the * or # characters, the Phone app does not attempt to dial the corresponding phone number.


I don’t know why this code compiles:

UIApplication.sharedApplication().openURL(NSURL(string: "tel//:1111111,,222##"))

NSURL(string:) is a failable initializer, meaning it returns an optional, and openURL()’s arg is non-optional. That cues you to do a check like this, which would prevent the crash:

if let url = NSURL(string: "tel//:1111111,,222##") {
UIApplication.sharedApplication().openURL(url)
} else {
showErrorMessage("Unable to dial this number")
}

Did you perhaps have an ! after the NSURL constructor that got dropped when you trimmed it for this question? If so, that would be the cause of your crash.



Related Topics



Leave a reply



Submit