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).
Thanks.

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.

4 Likes

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", "https://my-domain.com/version.txt", 10)
    
  If Result.Trim = "" Then
    ' no internet or some other error
    Return
  End If
  
  If Result.Trim.Length > 10 Then
    ' unrecognized response from server
    Return
  End If
  
  If Result.Trim <> "<my app version>" Then
    ' a new version is available
  Else
    ' you have the current version
  End If
      
End Sub
2 Likes

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