本文介绍了如何在iOS中获取没有互联网和GPS(可能是Carrier?)的用户国家的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获得没有互联网连接的用户国家和 GPS
。
信息
(CTTelephonyNetworkInfo * info = [CTTelephonyNetworkInfo new];
CTCarrier * carrier = info.subscriberCellularProvider;),
但是这提供了运营商的原始位置,而不是Active国家/地区。
例如,如果用户有 AT& T
SIM卡,并且他在法国,我可以获得美国
试一试
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?)的用户国家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!