3

I hope to call with * character. ex> *711313.

Currently, I'm using this code:

NSString *str = [NSString stringWithFormat:@"tel:%@", tmp];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];

I tested two cases:

  1. tmp = @"719929292"; //this is ok. make call.

  2. tmp = @"*7128282"; //app no reaction. not to call.

How can I call with *(star character)?

Cœur
  • 37,241
  • 25
  • 195
  • 267
YoungWoo Lee
  • 73
  • 1
  • 4

1 Answers1

0

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.

Jesper
  • 7,477
  • 4
  • 40
  • 57
  • Yes. If you have already added percent escapes to a string `NSString *escaped;`, you can do `[escaped stringByReplacingOccurrencesOfString:@"*" withString:@"%2A"]`. – Jesper Oct 16 '12 at 08:54
  • i found the answer.... https://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/PhoneLinks.html#//apple_ref/doc/uid/TP40007893-SW1 – YoungWoo Lee Oct 25 '12 at 06:08