如何在iOS中获取没有互联网和GPS(可能是Carrier?)的用户国家 [英] How to get user country without internet and gps (may be Carrier?) in iOS

查看:244
本文介绍了如何在iOS中获取没有互联网和GPS(可能是Carrier?)的用户国家的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得没有互联网连接的用户国家和 GPS



信息

 (CTTelephonyNetworkInfo * info = [CTTelephonyNetworkInfo new]; 
CTCarrier * carrier = info.subscriberCellularProvider;),

但是这提供了运营商的原始位置,而不是Active国家/地区。

例如,如果用户有 AT& T SIM卡,并且他在法国,我可以获得美国



<您可以尝试通过检查设备上选择的时区来获取用户的TimeZone城市,然后将其转换为通过使用设备上的本地数据库向该国提供。
试一试

  NSTimeZone * timeZone = [NSTimeZone localTimeZone]; //或者尝试[NSTimeZone systemTimeZone]; 
NSString * timeZoneName = [timeZone name];


I want to get user country without internet connection and GPS.

I tried getting user's Country using Carrier information

(CTTelephonyNetworkInfo *info = [CTTelephonyNetworkInfo new];
    CTCarrier *carrier = info.subscriberCellularProvider;), 

but this provides Carriers original location, not Active country.

For example if the user has AT&T sim card and he is in France, I get U.S.

Any suggestions?

解决方案

You can try getting the User's TimeZone city by checking the timeZone selected on the device and then translate that to the country by using a local database on the device . Give this a try

NSTimeZone *timeZone = [NSTimeZone localTimeZone]; // or try [NSTimeZone systemTimeZone];
NSString *timeZoneName = [timeZone name];

这篇关于如何在iOS中获取没有互联网和GPS(可能是Carrier?)的用户国家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆