对于那些感兴趣的人,我找到了一种简单的方法,使用NSLocale currentLocale
:
// Get the current locale.
NSLocale *currentLocale = [NSLocale currentLocale];
// Get country code, e.g. ES (Spain), FR (France), etc.
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
if ([countryCode isEqualToString:@"FR"]){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://0000000000"]];
}
else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://+33000000000"]];
}
if(SYSTEM_VERSION_LESS_THAN(@"7.0")) {
if ([countryCode isEqualToString:@"FR"]){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://0000000000"]];
}
else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:+ 33000000000"]];
}
}
效果很好。