0

私のアプリでは、選択した番号に電話をかけたいと思っています。このために、次のコードがあります

 +(void)makeCallToSelectedContact:(NSString*)phoneNo{

    NSMutableString *phoneNumber = [NSMutableString stringWithString:phoneNo];

    [phoneNumber replaceOccurrencesOfString:@" " 
                                 withString:@"" 
                                    options:NSLiteralSearch 
                                      range:NSMakeRange(0, [phoneNumber length])];
    [phoneNumber replaceOccurrencesOfString:@"(" 
                                 withString:@"" 
                                    options:NSLiteralSearch 
                                      range:NSMakeRange(0, [phoneNumber length])];
    [phoneNumber replaceOccurrencesOfString:@")" 
                                 withString:@"" 
                                    options:NSLiteralSearch 
                                      range:NSMakeRange(0, [phoneNumber length])];

    NSLog(@"phoneNumber => %@",phoneNumber);
    if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:+%@",phoneNumber]]]) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:+%@",phoneNumber]]];
    }
    else {
        NSLog(@"Unable to open");
        [self showAlertWithTitle:@"Alert" andMessage:@"This Device Doesn't Support Call Functionality"]; 
    }
}

+91 1234567890 のような電話番号がない場合、番号を正しく呼び出すとしましょう。しかし、1234567890 のような + & 国コードのない番号がある場合、それは間違った電話番号である +12 34567890 に変換されます。ここに私のコンソールログがあります

    2012-04-05 19:13:37.960 Search[22453:11003] phoneNumber => +911234567890

2012-04-05 19:13:47.928 Search[22453:11003] phoneNumber => 1234567890

私が欠けているものは何ですか?どんな種類の助けも大歓迎です。

4

1 に答える 1