How to get user country without internet and gps (may be Carrier?) in iOS

萝らか妹 提交于 2019-12-11 03:17:09

问题


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?


回答1:


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];


来源:https://stackoverflow.com/questions/25383585/how-to-get-user-country-without-internet-and-gps-may-be-carrier-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!