9

我正在尝试使用我的应用程序拨打电话

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://1800000002"]];

这是印度的免费电话号码。但在拨号时,它正在转换为 +1(800)-000-000(将拨号转换为美国号码)

我已将复制/粘贴电话号码引用到键盘中,当我在印度重拨免费电话号码时,iPhone 正在连接美国]。但找不到解决方案。

所以任何人都可以帮我避免这个ISD电话印度本地电话..

4

3 回答 3

2

telprompt 需要国际格式的号码。所以你需要把它转换成那个。我认为对于印度和您要拨打的号码,这应该是+911800000002

所以这应该工作:

NSURL *phoneURL = [NSURL URLWithString:@"telprompt://+911800000002"];
if ([[UIApplication sharedApplication] canOpenURL:phoneURL]) {
    [[UIApplication sharedApplication] openURL:phoneURL];
} else {
    // handle that case. e.g show number to user so that they can
    // type it in a phone manually or copy it to the clipboard and
    // notify user about that.
}

根据本地号码与国际格式在印度的工作方式相比,您可能需要删除1号码上的 ,对此不确定。

附注:在处理电话号码时,您应该始终使用国际格式。否则,当前位于目的地国家/地区之外的设备可能会呼叫其他人,或者根本无法拨打电话。

于 2016-05-12T07:08:19.820 回答
1

添加了县代码(对于印度:+91)

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://+911800000002"]];

找出国家代码的通用方法

NSLocale *currentLocale = [NSLocale currentLocale];  // get the current locale.
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; // get country code, e.g. ES (Spain), FR (France), etc.
于 2016-07-17T18:42:44.587 回答
0

如果您使用 telprompt,您的应用程序可能会被 Apple 拒绝。使用以下代码以编程方式拨打号码,并查看您输入的号码是否正确,格式正确。

NSString *phoneNumber = @"+1800000002;
NSString *phoneURLString = [NSString stringWithFormat:@"tel:%@", phoneNumber];
NSURL *phoneURL = [NSURL URLWithString:phoneURLString];
[[UIApplication sharedApplication] openURL:phoneURL];

来源:替换 tel 或 telprompt 调用

于 2016-04-29T12:44:35.843 回答