Reputation: 17637
I created an app using SDK 17134 .appinstaller, certificate, uploaded to server version 1.0.0.0;
User installs the App. (1.0.0.0)
User opens the App (1.0.0.0)
Then I publish a new version (1.0.0.2).
While the App is open, how can I check on the app that a new version is avaliable on the server, prompt the user and start app update to version 1.0.0.2?
Upvotes: 7
Views: 1917
Reputation: 5276
Windows 1809 introduced a couple of tools to help in this regard. You can use the Package.GetAppInstallerInfo() method to get the URI from the .AppInstaller.
AppInstallerInfo info = Windows.ApplicationModel.Package.Current.GetAppInstallerInfo();
You can also use Package.CheckUpdateAvailabilityAsync() to see if an update is available from the server indicated in the .AppInstaller.
PackageUpdateAvailabilityResult result = await currentPackage.CheckUpdateAvailabilityAsync();
switch (result.Availability)
{
case PackageUpdateAvailability.Available:
GoToUpdateAvailableUIView();
break;
case PackageUpdateAvailability.Required:
GoToUpdateRequiredUIView();
break;
case PackageUpdateAvailability.NoUpdates:
ShowNoUpdateAvailableDialog();
break;
case PackageUpdateAvailability.Unknown:
default:
// Log and ignore or whatever
break;
}
Upvotes: 5
Reputation: 39072
As the .appinstaller
file is just an XML file, you can request its contents from your server and then check for the version inside. You can then compare it with Package.Current.Id.Version
and in case it is newer, you may notify the user to close the app to update it. This however presumes the system has already checked ahead that the update is available, which depends on what you have selected in the dialog while creating the package:
If you are checking for updates everytime the application runs, just display the prompt after a slight delay to make sure the system has had time to find out about the new version. If you have set an interval, it is more tricky, so you could ideally notify the user after two-times longer interval than you have set, so that you can be sure that the system check has gone through before that.
Upvotes: 2