private async Task CheckAndOpenAppStoreAsync() { UpdatesCheckResponse response = await checkForUpdatesFunction(); if (response.IsNewVersionAvailable && await mainPage.DisplayAlert(title, message, confirm, cancel)) { DependencyService.Get <IStoreOpener>().OpenStore(); } }
private async Task CheckAndUpdateAsync() { UpdatesCheckResponse response = await checkForUpdatesFunction(); if (response.IsNewVersionAvailable && await mainPage.DisplayAlert(title, message, confirm, cancel)) { if (Device.RuntimePlatform == Device.UWP || Device.RuntimePlatform == Device.Android) { HttpResponseMessage httpResponse = await new HttpClient().GetAsync(response.DownloadUrl); byte[] data = await httpResponse.Content.ReadAsByteArrayAsync(); string fileName = response.DownloadUrl.Substring(response.DownloadUrl.LastIndexOf("/") + 1); DependencyService.Get <IFileOpener>().OpenFile(data, fileName); } else { throw new AutoUpdateException("Only Android and UWP are supported for automatic installation."); } } }