How to code the checking of the version of an App ?

조회 수: 24 (최근 30일)
Marc Servagent
Marc Servagent 2020년 7월 29일
댓글: Francisco Sacchetti 2024년 1월 19일
Hello,
I made an App via AppDesigner. The App is shared via App Installer.
I woud like to code the following:
When the app is running, I would like to check the current version of the app, and check if more recent version of app exists.
How to code this ?
Many thanks
  댓글 수: 5
Marc Servagent
Marc Servagent 2020년 7월 30일
done
Wolf Blecher
Wolf Blecher 2022년 5월 10일
Is it possible to upvote this feature request?

댓글을 달려면 로그인하십시오.

채택된 답변

Marc Servagent
Marc Servagent 2020년 7월 31일
The technical support team indicated me the answer, which allow to update the answer to my own question!
Attached is the function which allow to check the new version of the app, and hereafter is an example provided by the technical support team:
>> checkForNewVersion('C:\Users\%username%\Documents\MATLAB\Clock.mlappinstall','Clock')
ans =
logical 0
greetings!
  댓글 수: 1
Adam Danz
Adam Danz 2020년 7월 31일
Did they provide a description of what the two inputs should be?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Brian
Brian 2021년 11월 16일
I developed the below yesterday and it has seemed to work so far.
function ver = CheckVersion(~)
if isdeployed % If compiled and deployed
[~, result] = system('path');
p = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once')); % Get run path
myDir=dir(fullfile(p,'..','appdata','components')); % Move to components folder and get all files
myDir=myDir(3:end); % Exclude '.' and '..'
validFile=myDir(datetime({myDir.date})==max(datetime({myDir.date}))); % Only look at most recent install, includes 'common' and 'platform'
appInfo=xml2struct(fullfile(validFile(1).folder,validFile(1).name)); % Import 'common' as struct from xml (requires xml2struct download)
ver=appInfo.componentData.component.componentVersion.Text; % Grab the version number as a char array
else
fullpath=mfilename('fullpath'); % Get run path
s=settings;
if ~isempty(strfind(fullpath,s.matlab.addons.InstallationFolder.ActiveValue)) % If the run path includes the addons install folder, it is run from the app bar
[p,~]=fileparts(fullpath); % Get the path
if isfolder(fullfile(p,'resources'))
xmlLocation=fullfile(p,'resources','addons_core.xml'); % Go to resources folder
appInfo=xml2struct(xmlLocation); % Import addons_core.xml as struct
ver=appInfo.addonCore.version.Text; % Grab the version number as a char array
else
ver='debug'; % This may be redundant with below. Left in to prevent errors just in case...
end
else % If run from MATLAB mlapp file
ver='debug';
end
end
end
  댓글 수: 4
Brian
Brian 2022년 4월 6일
Check my comment above. It accesses the *.xml file that is created when you either compile the app into a *.exe or distribute it as an app for the app bar. From there it pulls the version number that was set in the App Details (or more specifically in the Share App window).
Francisco Sacchetti
Francisco Sacchetti 2024년 1월 19일
I cannot make this work in the webbappserver

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Downloads에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by