Get the WAN IP in the iOS app - ios

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?

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.

Related

Connect to a peer based on IP address and port

I've got an app that supports Bonjour and manually connecting to an IP (all within the same local network). I'm now looking at whether I can use MPC instead and while it obviously would be able to replace Bonjour, I haven't seen anything that allows me to replace the functionality around manually connecting to the IP. For context, my app runs in networks that have multicast disabled which is when users fall back to manually entering the IP address.
I could have the receiving app host a webserver and send a request there. Could I create a Peer based on the ip:port combination? That would allow me to make use of MPC for the MCSession aspect.
Is it possible to set up a Multipeer Connection based on an ip:port rather than having it automatically discovered via multicast?
I'll go with a solution based on NWConnection which uses NWEndpoint and can be created with both IP:port and a Bonjour-established service.
If I would've had access to the full Network.framework then I could've used that for both discovery & communication but due to SDK constraints I'll be using MultipeerConnectivity for the discovery aspect instead. By providing the device its IP & port when broadcasting the Bonjour service, another device can discover it automatically and then use the extra info to create an IP:port-based NWConnection.

Twitter API: How to get sender IP Address?

I would like to get the IP Address / hostname / device (ios, android, web) for a specific tweet via Twitter API or anything similar.
Is that possible ?
There's absolutely no way to get IP address or hostname. That would be a massive privacy violation.
You can make a very rough guess at device by looking at the source parameter of a Tweet.
If it says "source":"Twitter for iPhone" you'll know it is coming from an iPhone. Not every source says which device it is running on.

How to get the IP address of the associated access point on an iOS device

Use Case:
We have an iOS application where you can run a network test between an iOS device and its associated wireless access point to test throughput. The app can get the IP address of the iOS device just fine, but the user has to type in the IP of the access point.
Problem:
The task is to get the IP address of the associated access point, and pre fill it for the user, hence avoiding user intervention there.
My Approach:
Find out the Mac Address/BSSID of the access point.
I do this by employing the Captive Network API.
Issue an ARP request to find out the IP associated to the access point.
I haven't been able to accomplish this as of yet. Google and SO search has kind of lead me to a dead end here. Here are some similar questions:
How do I query the ARP table on iPhone? AND
ARP Requests on iPhone
Question:
What is the right way to do this? In fewer words, what is the best way to get the IP address of the access point an iOS device is connected to.
A WiFi access point is not necessarily an IP-capable device (although many of them are, but for configuration, not communications, purposes).
Even if you do get the actual access point's IP address, how are you going to test the throughput? You could send ICMP Echo requests, but that will just give you instantaneous round-trip times, not throughput, and many IP devices, for security reasons, are configured to not respond to ICMP ECHO requests.
BSSID is unique for each SSID on each Radio and it differs from the Access Point’s Mac Address. If you compare them you can see last characters of Mac Adresses are different for BSSID and the AccessPoint.

How does the iOS Reachability class work, and why the IP Address 169.254.0.0?

How does the iOS Reachability class work, and what's so special about the IP Address 169.254.0.0?
I'm trying to figure out whether Wi-Fi is on, independent of whether it is connected to an actual Wi-Fi network or not.
I haven't found a satisfactory answer for this question on SO, and even the answers that try to answer this don't work for me.
When you fail to get an IP address from DHCP, it will automatically assign you a random address in the 169.254.x.x range. So if you have an IP address like this, it means you're connected to a network, and set to use DHCP to get an address, but it is unable to obtain an IP address from DHCP.
There doesn't appear to be any way to simply detect if wifi is enabled and not connected to a network, so I think you're out of luck there. The best you can do is detect if you're connected to a wifi network, but often if you're out and about, you won't be connected to a wifi network even though it is enabled.

How can I get Carrier and IP Address and Device Id on J2ME?

How can I get Carrier and IP Address and Device Id on J2ME?
There is no standard way to get these information on JavaME however on Nokia platforms there are some Nokia specific system properties that you can use. com.nokia.mid.imsi and com.nokia.mid.networkid may be interesting for your case.
For the IP address I suggest that you use a server side call to retrieve the IP address from referrer.

Resources