How to get roaming status in iOS

I want to receive notifications when I enter the roaming zone in my iOS application, I already read the documentation for NSLocale , SCNetworkReachability and basic telephony (maybe I missed something). I need to get this information from sim (or in any other way, if possible).

+6
source share
2 answers

The usual way would be to get the country code of the operator from the main telephony interface, and then compare this with the country code with reverse geocoding of the location.

Advantages: works with VPN and when the user disconnected data when roaming. Disadvantages: does not work without space.

I don’t have a code that is not related to copyright for you, but the key you need in the place you need for the country code is @CountryCode, Geocoding will look something like this: -

 CLGeocoder* geocoder = [[CLGeocoder alloc] init]; [geocoder reverseGeocodeLocation:location completionHandler: ^(NSArray* placemarks){}] 

The country code for the provider will be

 NSString* homeCountry = [netInfo.subscriberCellularProvider isoCountryCode]; 

Hope this helps

+2
source

There is no iOS API for determining roaming status, but you can use third-party services such as http://ipinfo.io (my own service) to find out the current country of an even operator code based on the IP address of the device. You can then compare this with the details of CTCarrier to determine if the device is roaming. Here's the standard ipinfo.io API response:

 $ curl ipinfo.io/24.32.148.1 { "ip": "24.32.148.1", "hostname": "doc-24-32-148-1.pecos.tx.cebridge.net", "city": "Pecos", "region": "Texas", "country": "US", "loc": "31.3086,-103.5892", "org": "AS7018 AT&T Services, Inc.", "postal": "79772" } 

Custom packages are available, which also include mnc / mcc data for mobile IPs. See http://ipinfo.io/developers for more details.

+1
source

Source: https://habr.com/ru/post/949627/


All Articles