Check if an update is available

Hello, I am looking for a routine, as simple as possible, to read a text file on my website in https (in a /public folder) which includes the latest version number in order to compare it to the current version of my application (App. Version).

Well who stops you, Check URLConnection in XOJO or Kaju on git if you want something more complex

Check out Kaju. See GitHub - ktekinay/Kaju: Xojo code for implementing self-updating apps . It’s easy to implement.

Thanks. The last update of Kaju was 2 years ago… and I don’t want to download the update, just check it.

FYI, it hasn’t been updated because it hasn’t needed an update.


Excellent news

I’ve been using this. (Untested as-is because I removed proprietary references and tried to make it generic.)

Public Sub CheckVersion()
  Dim Result As String
  Dim w As URLConnection

  Result = w.SendSync("GET", "", 10)
  If Result.Trim = "" Then
    ' no internet or some other error
  End If
  If Result.Trim.Length > 10 Then
    ' unrecognized response from server
  End If
  If Result.Trim <> "<my app version>" Then
    ' a new version is available
    ' you have the current version
  End If
End Sub

Thank you very much.

Needs “w = new URLConnection” and also a “Try… catch… end Try…” to catch exceptions… except that if the URL is invalid you’ll get error -1004 (cannot find host) which is kinda cute because it throws a NetworkException which isn’t intercepted by either:

Catch NetworkException… or
Catch RuntimeException…

… despite what the documentation claims, NetworkException is not caught.
… so, is there a possible bug with the exception handling ?

I made this for my desktop application, it compares the app version with the package file name you put on the cloud. It is simple att works nice.

1 Like