ios - 获取 iPhone 所在的国家(没有 CLLocationManager)

标签 ios objective-c

我开发了一个看电视的应用程序,我们公司只有在一个国家/地区提供服务的许可证。
因此,要求是获取 iPhone 当前所在的国家/地区。

我一直在 StackOverflow 上寻找答案,找到了一些很棒的主题,但它们并不完全符合本案例的要求:

Get device location (only country) in iOS - 在我们的案例中使用 CLLocationManager 是 Not Acceptable ,因为它需要用户始终保持地理定位服务,耗尽手机电池,并且我们需要用户的适当许可。

Find current country from iPhone device - 在我们的案例中使用 NSLocale 是 Not Acceptable ,因为它只提供用户选择他的手机的设置,它可能不同于 iPhone 当前实际所在的国家/地区。
< br/> iOS how to find country code of the user's phone number? - 我们尝试使用 CTCarrier,测试它向国外发送 SIM 卡:CTCarrier 返回了 SIM 卡所在国家/地区的代码,而不是 iPhone 当前所在国家/地区的代码。

Roaming Status in iPhone - 我发现的唯一可行的解​​决方案是检测漫游状态,但它使用未记录的系统文件,所以我担心如果我使用此应用程序可能会被 App Store 拒绝:

static NSString *carrierPListSymLinkPath = @"/var/mobile/Library/Preferences/com.apple.carrier.plist";
static NSString *operatorPListSymLinkPath = @"/var/mobile/Library/Preferences/com.apple.operator.plist";

- (BOOL)isRoaming
{
    NSFileManager *fm = [NSFileManager defaultManager];
    NSError *error;
    NSString *carrierPListPath = [fm destinationOfSymbolicLinkAtPath:carrierPListSymLinkPath error:&error];
    NSString *operatorPListPath = [fm destinationOfSymbolicLinkAtPath:operatorPListSymLinkPath error:&error];

   return (![operatorPListPath isEqualToString:carrierPListPath]);
}

如何解决?请帮忙。
提前致谢。

最佳答案

您可以通过IP地址获取当前国家。 更多信息您可以获得there .

关于ios - 获取 iPhone 所在的国家(没有 CLLocationManager),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45164442/

相关文章:

ios - 设置 UIPrintPageRenderer/UIPrintInteractionController 要打印的页面

android - UI 应该中断的最长时间是多少?

iphone - IOS 中的 Facebook 集成

ios - 使用 NSOperationQueue 在线程之间移动变量

ios - XCode 无法启动应用程序 "The operation could not be completed (FBSOpenApplicaionpplicaionErrorDomain error 3.)"

iOS:NSString 与 C malloc 的错误和崩溃

Objective C 中的 C++ 函数

iphone - NSDate - timeIntevalSinceDate -

iphone - 从 NSDate 获取时区名称

objective-c - XCode 4 存档/IPA 错误 : "The operation couldn’ t be completed. 没有这样的文件或目录”