-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// AutoUpdatemanager.swift | ||
// HackerNews | ||
// | ||
// Created by Itay Brenner on 31/1/25. | ||
// | ||
|
||
#if ADHOC | ||
import UIKit | ||
import Foundation | ||
import ETDistribution | ||
|
||
struct AutoUpdateManager { | ||
@MainActor static func checkForUpdates() { | ||
let params = CheckForUpdateParams(apiKey: Constants.Distribution.apiKey) | ||
ETDistribution.shared.checkForUpdate(params: params) { result in | ||
switch result { | ||
case .success(let releaseInfo): | ||
if let releaseInfo { | ||
print("Update found: \(releaseInfo)") | ||
guard let url = ETDistribution.shared.buildUrlForInstall(releaseInfo.downloadUrl) else { | ||
return | ||
} | ||
DispatchQueue.main.async { | ||
UIApplication.shared.open(url) { _ in | ||
exit(0) | ||
} | ||
} | ||
} else { | ||
print("Already up to date") | ||
} | ||
case .failure(let error): | ||
print("Error checking for update: \(error)") | ||
} | ||
} | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Constants.swift | ||
// HackerNews | ||
// | ||
// Created by Itay Brenner on 31/1/25. | ||
// | ||
|
||
import Foundation | ||
|
||
enum Constants { | ||
enum Distribution { | ||
static let apiKey = "API_KEY" | ||
} | ||
} |