private async void UpdateButton_Click(object sender, RoutedEventArgs e) { statusTextBlock.Text = "Getting the latest update information..."; var path = "http://localhost:5000/install/SampleApp.appinstaller"; var info = await AutoUpdateManager.CheckForUpdatesAsync(path); if (!info.Succeeded) { statusTextBlock.Text = info.ErrorMessage; return; } if (!info.ShouldUpdate) { statusTextBlock.Text = "This app is already up-to-date :)"; return; } // You can use info.MainBundleVersion to get the update version statusTextBlock.Text = $"New version: {info.MainBundleVersion}"; var result = await AutoUpdateManager.TryToUpdateAsync(info); if (!result.Succeeded) { statusTextBlock.Text = result.ErrorMessage; return; } statusTextBlock.Text = $"Success! The app will be restarted soon, see you later!"; }
public MainPage() { Current = this; this.InitializeComponent(); Window.Current.CoreWindow.CharacterReceived += CoreWindow_CharacterReceived; // Set title bar var coreTitleBar = CoreApplication.GetCurrentView().TitleBar; Package package = Package.Current; AppTitle.Text = string.Format("{0} {1}.{2}.{3}.{4}", "Forecast", package.Id.Version.Major, package.Id.Version.Minor, package.Id.Version.Build, package.Id.Version.Revision); coreTitleBar.ExtendViewIntoTitleBar = true; Window.Current.CoreWindow.SizeChanged += (s, e) => UpdateAppTitle(); coreTitleBar.LayoutMetricsChanged += (s, e) => UpdateAppTitle(); nav.BackRequested += Nav_BackRequested; Window.Current.Activated += Current_Activated; ChangelogManager.AddChangelogForVersion("1.0.5.0", typeof(Changelogs._1_0_5_0)); ChangelogManager.AddChangelogForVersion("1.0.6.0", typeof(Changelogs._1_0_6_0)); ChangelogManager.AddChangelogForVersion("1.0.7.0", typeof(Changelogs._1_0_7_0)); ChangelogManager.AddChangelogForVersion("1.0.8.0", typeof(Changelogs._1_0_8_0)); try { _ = ChangelogManager.ShowChangelogForCurrentVersionIfNotPreviouslyShown(); } catch (UWPTools.Exceptions.ChangelogNotFoundForCurrentVersionException) { /* Ignore this - there's no changelog for this version */ } // Run auto-update and show the manual update button if an update can be installed. // The update section will return from the call early if an error occurs or for control flow. _ = Task.Run(async() => { try { var path = "http://ror2modman.ethanbrews.me/Forecast.appinstaller"; ApplicationUpdateInformation = await AutoUpdateManager.CheckForUpdatesAsync(path); if (!ApplicationUpdateInformation.Succeeded) { System.Diagnostics.Debug.WriteLine("AutoUpdateManager Failed"); Analytics.TrackEvent(AnalyticsEventNames.DwrandazUpdateManager, new Dictionary <string, string> { { "event", "CheckFailed" }, { "message", ApplicationUpdateInformation.ErrorMessage.ToString() } }); return; } var shouldShowTip = ApplicationSettings.LastNavigationUpdateButtonTeachingTipShown.Value == 0; ApplicationSettings.Increment_LastNavigationUpdateButtonTeachingTipShown(); System.Diagnostics.Debug.WriteLine($"ApplicationSettings.LastNavigationUpdateButtonTeachingTipShown.Value = {ApplicationSettings.LastNavigationUpdateButtonTeachingTipShown.Value}"); await UWPTools.Threads.ThreadHelper.RunInUIThread(() => { if (ApplicationUpdateInformation.ShouldUpdate) { UpdateLauncherButton.Visibility = Visibility.Visible; } if (shouldShowTip && ApplicationUpdateInformation.ShouldUpdate) { UpdateLauncherButtonTeachingTip.IsOpen = true; } }); } catch (Exception ex) { Analytics.TrackEvent(AnalyticsEventNames.DwrandazUpdateManager, new Dictionary <string, string> { { "event", "UncaughtError" }, { "type", ex.GetType().ToString() }, { "message", ex.Message.ToString() } }); } }); }