private async Task <bool> PromptUpdate(Plugin.XF.AppInstallHelper.Abstractions.Version newVerInfo) { bool confirmUpdate = true; if (newVerInfo.ForceUpdate) { await DisplayAlert($"New version {newVerInfo.VersionName} occur", $"Release notes : \r\n{newVerInfo.ReleaseNotes}", "Update"); } else { confirmUpdate = await DisplayAlert($"New version {newVerInfo.VersionName} occur", $"Release notes : \r\n{newVerInfo.ReleaseNotes}", "Update", "Skip"); } return(confirmUpdate); }
private async Task installUpdate(Plugin.XF.AppInstallHelper.Abstractions.Version updatedVersion) { if (updatedVersion.VersionCode > int.Parse(Xamarin.Essentials.VersionTracking.CurrentBuild)) { bool confirmUpdate = await PromptUpdate(updatedVersion); if (confirmUpdate) { string installPath = string.Empty; if (Device.RuntimePlatform == Device.iOS) { installPath = updatedVersion.iOSPath; } else { installPath = System.IO.Path.Combine(Plugin.XF.AppInstallHelper.CrossInstallHelper.Current.GetPublicDownloadPath(), "APK.APK"); using (HttpClient hc = new HttpClient()) { var response = await hc.GetAsync(updatedVersion.AndroidPath); var byteArray = await response.Content.ReadAsByteArrayAsync(); System.IO.File.WriteAllBytes(installPath, byteArray); } } bool result = await Plugin.XF.AppInstallHelper.CrossInstallHelper.Current.InstallApp(installPath, Abstractions.InstallMode.OutOfAppStore); } } else { await DisplayAlert("Alert", "There is no more update", "OK"); } }