Is there any way to determine if the iphone is roaming?

前端 未结 3 1684
太阳男子
太阳男子 2020-11-28 06:38

I am working on an iPhone application and would really like to determine if the device is roaming so that I can intelligently avoid costing my users expensive connections if

3条回答
  •  萌比男神i
    2020-11-28 07:05

    On a non-jailbreak device you can use third party services like http://ipinfo.io (my own service) to find out the current country of even carrier code based on the device's IP address, and you can then compare that to the CTCarrier details 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 that also include the mnc/mcc details of mobile IPs though. See http://ipinfo.io/developers for details.

提交回复
热议问题