Reputation: 1875
So I need to retrieve the user's WAN IP from within the app I am building. I saw this answer here: iPhone/iPad/OSX: How to get my IP address programmatically?
But this only returns the user's IP address in the local network.
By what means can I know the user's WAN IP from within the app?
Upvotes: 1
Views: 2472
Reputation: 13783
The easiest way to get your wap ip address is to use NSURLConnection
.
For the URL you can use: http://www.whatismyip.com/m/mobile.asp or http://www.dyndns.org/cgi-bin/check_ip.cgi
Just parse the return data and you have your external ip address. A complete implementation is shown here. It is not the most efficient way, but it works.
Upvotes: 1