Downloads latest _available_ version when updating from AppViewController

Asks user to fall back to latest supported verson if version is not compatible with device’s iOS version.
This commit is contained in:
Riley Testut
2023-12-01 16:03:06 -06:00
parent 2c1ffedfe3
commit 92f3be07f6
3 changed files with 47 additions and 30 deletions

View File

@@ -360,13 +360,21 @@ private extension AppViewController
{
func update()
{
var buttonAction: AppBannerView.AppAction?
if let installedApp = self.app.installedApp, let latestVersion = self.app.latestAvailableVersion, !installedApp.matches(latestVersion)
{
// Explicitly set button action to .update if there is an update available, even if it's not supported.
buttonAction = .update
}
for button in [self.bannerView.button!, self.navigationBarDownloadButton!]
{
button.tintColor = self.app.tintColor
button.isIndicatingActivity = false
}
self.bannerView.configure(for: self.app)
self.bannerView.configure(for: self.app, action: buttonAction)
let title = self.bannerView.button.title(for: .normal)
self.navigationBarDownloadButton.setTitle(title, for: .normal)
@@ -498,9 +506,9 @@ extension AppViewController
{
if let installedApp = self.app.installedApp
{
if let latestVersion = self.app.latestSupportedVersion, !installedApp.matches(latestVersion)
if let latestVersion = self.app.latestAvailableVersion, !installedApp.matches(latestVersion)
{
self.updateApp(installedApp)
self.updateApp(installedApp, to: latestVersion)
}
else
{
@@ -551,7 +559,7 @@ extension AppViewController
UIApplication.shared.open(installedApp.openAppURL)
}
func updateApp(_ installedApp: InstalledApp)
func updateApp(_ installedApp: InstalledApp, to version: AppVersion)
{
let previousProgress = AppManager.shared.installationProgress(for: installedApp)
guard previousProgress == nil else {
@@ -560,7 +568,7 @@ extension AppViewController
return
}
_ = AppManager.shared.update(installedApp, presentingViewController: self) { (result) in
AppManager.shared.update(installedApp, to: version, presentingViewController: self) { (result) in
DispatchQueue.main.async {
switch result
{