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
committed by Magesh K
parent a981201016
commit 8946ab8a65
3 changed files with 56 additions and 26 deletions

View File

@@ -570,9 +570,9 @@ extension AppManager
}
@discardableResult
func update(_ installedApp: InstalledApp, presentingViewController: UIViewController?, context: AuthenticatedOperationContext = AuthenticatedOperationContext(), completionHandler: @escaping (Result<InstalledApp, Error>) -> Void) -> Progress
func update(_ installedApp: InstalledApp, to version: AppVersion? = nil, presentingViewController: UIViewController?, context: AuthenticatedOperationContext = AuthenticatedOperationContext(), completionHandler: @escaping (Result<InstalledApp, Error>) -> Void) -> Progress
{
guard let appVersion = installedApp.storeApp?.latestSupportedVersion else {
guard let appVersion = version ?? installedApp.storeApp?.latestSupportedVersion else {
completionHandler(.failure(OperationError.appNotFound(name: installedApp.name)))
return Progress.discreteProgress(totalUnitCount: 1)
}