2013-09-06 3 views
1

을 먼저 사용하십시오. 죄송합니다. 나는 영어를 잘 못해.xcode에서 전화 번호 "# 51234"로 전화하고 싶습니다. telprompt

xcode에서 telprompt를 사용하여 전화 번호 "# 51234"로 전화하고 싶습니다.

그러나 telprompt는이를 거부합니다.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://#5%@", nzoneNum]]]; 

nzomeNum는 "1234"

나는이 문제를 해결할 수 있습니다.

답변

2

좀 도와주세요 .. 불행하게도 당신은 해시 태그를 포함한 모든 번호로 전화를 걸 수 없습니다. 애플이 명확하게 그 통화를 제한합니다 iPhoneURLScheme_Reference

는 악의적으로 전화를 리디렉션하거나 전화 또는 계정의 동작을 변경하지 못하도록하기 위해 휴대 전화 앱은 대부분 지원하지만 모든의 전화 방식의 특수 문자. 특히 URL에 * 또는 # 문자가 포함 된 경우 전화 앱은 해당 전화 번호로 전화를 걸지 않습니다.

0

적어도 해시 태그 (#) 또는 별표 (*) 전화 번호 아이폰 OS (11), 하나의 등.

만들기 다음 tel: 접두사를 추가하고, 마지막으로 URL에 결과 문자열을 돌려, 전화 번호를 인코딩 첫 하여 이러한 문자를 호출합니다. 스위프트 4

IO에서 11

// set up the dial sequence 
let nzoneNum = "1234" 
let prefix = "#5" 
let dialSequence = "\(prefix)\(nzoneNum)" 

// "percent encode" the dial sequence with the URL Host allowed character set 
guard let encodedDialSequence = 
    dialSequence.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) else { 
    print("Unable to encode the dial sequence.") 
    return 
} 

// add the `tel:` url scheme to the front of the encoded string 
let dialURLString = "tel:\(encodedDialSequence)" 

// set up the URL with the scheme/encoded number string 
guard let dialURL = URL(string: dialURLString) else { 
    print("Couldn't make the dial string into an URL.") 
    return 
} 

// dial the URL 
UIApplication.shared.open(dialURL, options: [:]) { success in 
    if success { print("SUCCESSFULLY OPENED DIAL URL") } 
    else { print("COULDN'T OPEN DIAL URL") } 
} 

오브젝티브 C IO에서 11

// set up the dial sequence 
NSString *nzoneNum = @"1234"; 
NSString *prefix = @"#5"; 
NSString *dialSequence = [NSString stringWithFormat:@"%@%@", prefix, nzoneNum]; 

// set up the URL Host allowed character set, and "percent encode" the dial sequence 
NSCharacterSet *urlHostAllowed = [NSCharacterSet URLHostAllowedCharacterSet]; 
NSString *encodedDialSequence = [dialSequence stringByAddingPercentEncodingWithAllowedCharacters:urlHostAllowed]; 

// add the `tel` url scheme to the front of the encoded string 
NSString *dialURLString = [NSString stringWithFormat:@"tel:%@", encodedDialSequence]; 

// set up the URL with the scheme/encoded number string 
NSURL *dialURL = [NSURL URLWithString:dialURLString]; 

// set up an empty dictionary for the options parameter 
NSDictionary *optionsDict = [[NSDictionary alloc] init]; 

// dial the URL 
[[UIApplication sharedApplication] openURL:dialURL 
            options:optionsDict 
         completionHandler:^(BOOL success) { 
          if (success) { NSLog(@"SUCCESSFULLY OPENED DIAL URL"); } 
          else { NSLog(@"COULDN'T OPEN DIAL URL"); } 
         }];