You could get the user's IP address and use a geolocation database to guess their location based on that as described here: https://en.wikipedia.org/wiki/IP_address_location . If you are just concerned with region, you can probably find some data at regional internet registries (https://en.wikipedia.org/wiki/Regional_Internet_registry) websites to help you, since they control all the IP addresses for a particular region.
iOS - Determine User's country without using CLLocationManager
-
02-06-2022 - |
문제
I don't need precise location data, and I don't want the user to see the "This App wants to determine your location" Alert. I just need to determine the user's country, assuming they have an internet connection via network or wi-fi.
What is the best way to do this? Is there some way to use their IP?
This would only work if they had a carrier:
CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netInfo subscriberCellularProvider];
NSString *mcc = [carrier mobileCountryCode];
And NSLocale
is not reliable in that the user can change it in their device settings. Can't use the device's language setting for the same reason. I need the country based on where they are physically located.
해결책
다른 팁
Refer this url How can whatsapp know country code upon first run on iphone.. Hope this question and the question in the url i have given works for you
제휴하지 않습니다 StackOverflow