I spent some time a while ago trying to figure out how the get the version number of a SharePoint-Hosted App in JavaScript code. After a bunch of Googling and building demo Apps I gave up with the assumption that this information was not available.
This morning I was writing some code that worked with the property bag (AllProperties) values of the AppWeb. In there I noticed a property named Version. Hold on, could it be??? Yes, it could.
The value of the Version property in the App Web property bag is the version number of the App. 🙂
UPDATE (April 5, 2016):
It appears, as Ivan mentions in his comment, that the Version property is only added when you deploy using Visual Studio (i.e. during development). The property is not added when you install an app from the App Store or App Catalog. I’ve contacted Microsoft for more information about this but, as yet, I have not received a response.
The strategy I’m going to try is to use the version number of the Feature that is contained within the Sandbox Solution which is contained within the App. This does mean that the developer needs to keep the Feature version in sync with the App version, which is not optimal, but I don’t see a better way to solve the problem.
Unfortunately, this appears to be only in apps deployed with Visual Studio. Apps added from the App Catalog do not have the Version property.
You’re correct. I’ve updated the blog post to reflect this.