This post was originally posted in 2017 and has been updated in this post using Xojo API 2.0.
ipify is a very useful web service (an API) that promises to always be available to attend requests, letting us know the public (or external) IP address we are using to connect to Internet. We can get this information as pure Text or in JSON or XML formats.
There are plenty of times when your Xojo apps might need to know the public or external IP address is, and there are a lot of web sites or services that you can use with Xojo to find that.
I found ipify to be easy to use, plus it is easily available due to being hosted by Heroku. That means, for example, that if half the Internet is down…you still can be confident to reach the ipify service.
Using ipify from a Xojo desktop apps is as simple as using this code:
Var request as New URLConnection
Dim s as String = request.SendSync("GET","https://api.ipify.org",10)
But sometimes we need additional information; for example if the IP address has changed over time, or simply periodically checking for IP address changes. That is something that you can find in the ipify project for Xojo available here.
ipify for Xojo is designed as a Singleton class, that means that you even don’t need to instatiate it in order to get the current IP address, know if the IP has changed over time, or even instruct the class to periodically check for the IP address, notifying the registered object every time with the current IP address and if it is the same or has changed from the last time it was checked.