0

I'm developing a PhoneGap application, which involves using the native dialer. I'm using this code to dial numbers programmatically:

(void) dialPhone:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options {
    NSString* url;
    NSString* number = [options valueForKey:@"number"];
    //NSLog(@"number: %@", number);
    if([number hasPrefix:@"tel://"]) {
        url = number;
    }
    else {
        // escape characters such as spaces that may not be accepted by openURL
        url = [NSString stringWithFormat:@"tel://%@", number];
    }

    [[UIApplication sharedApplication]
     openURL:[NSURL URLWithString:url]];
}

And it works perfectly with one exception: I can't dial numbers like '10' (full url is tel://10). The application simply does nothing. No alerts, no errors. However, if I add some more symbols before the actual number I need, like '000', it works. Really looking for some guidance.

4

1 回答 1

0

如果有人遇到同样的问题,这是我的解决方法:我在数字后面加上了 '?1',所以完整的 URL 变成了 'tel:10?1',这样就成功了。

于 2013-08-05T07:52:26.160 回答