From 617c8354b7dcfca58d6ef84a903cee4617e8c8d5 Mon Sep 17 00:00:00 2001 From: gemcoder21 <104884878+gemcoder21@users.noreply.github.com> Date: Tue, 24 Sep 2024 17:28:00 +0100 Subject: [PATCH] Upgrade core to check new release api --- Gem/Core/Services/OnstartAsyncService.swift | 19 +++++++++++-------- Packages/Primitives/Sources/Config.swift | 16 +++++++++++++++- Packages/Primitives/Sources/Platform.swift | 10 ++++++++++ core | 2 +- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Gem/Core/Services/OnstartAsyncService.swift b/Gem/Core/Services/OnstartAsyncService.swift index b3fe75f4..7b00e14a 100644 --- a/Gem/Core/Services/OnstartAsyncService.swift +++ b/Gem/Core/Services/OnstartAsyncService.swift @@ -79,7 +79,7 @@ class OnstartAsyncService { } } } - + if versions.swapAssets > preferences.swapAssetsVersion { Task { do { @@ -90,18 +90,21 @@ class OnstartAsyncService { } } } - - let newVersion = config.app.ios.version.production - if VersionCheck.isVersionHigher(new: newVersion, current: Bundle.main.releaseVersionNumber) { - NSLog("Newer version available") - updateVersionAction?(newVersion) + #if RELEASE + if let newVersion = config.releases.first(where: { $0.store == .appStore }), + VersionCheck.isVersionHigher(new: newVersion.version, current: Bundle.main.releaseVersionNumber) { + NSLog("Newer version available") + updateVersionAction?(newVersion.version) } + #endif } catch { NSLog("Fetching config error: \(error)") } - + + #if RELEASE RateService().perform() - + #endif + Task { try await deviceService.update() } diff --git a/Packages/Primitives/Sources/Config.swift b/Packages/Primitives/Sources/Config.swift index 79065bb0..398975d7 100644 --- a/Packages/Primitives/Sources/Config.swift +++ b/Packages/Primitives/Sources/Config.swift @@ -42,6 +42,18 @@ public struct ConfigApp: Codable { } } +public struct Release: Codable { + public let version: String + public let store: PlatformStore + public let upgrade_required: Bool + + public init(version: String, store: PlatformStore, upgrade_required: Bool) { + self.version = version + self.store = store + self.upgrade_required = upgrade_required + } +} + public struct ConfigVersions: Codable { public let fiatAssets: Int32 public let swapAssets: Int32 @@ -54,10 +66,12 @@ public struct ConfigVersions: Codable { public struct ConfigResponse: Codable { public let app: ConfigApp + public let releases: [Release] public let versions: ConfigVersions - public init(app: ConfigApp, versions: ConfigVersions) { + public init(app: ConfigApp, releases: [Release], versions: ConfigVersions) { self.app = app + self.releases = releases self.versions = versions } } diff --git a/Packages/Primitives/Sources/Platform.swift b/Packages/Primitives/Sources/Platform.swift index 4d4f15b6..5e920993 100644 --- a/Packages/Primitives/Sources/Platform.swift +++ b/Packages/Primitives/Sources/Platform.swift @@ -8,3 +8,13 @@ public enum Platform: String, Codable, Equatable { case ios case android } + +public enum PlatformStore: String, Codable, CaseIterable, Equatable { + case appStore + case googlePlay + case fdroid + case huawei + case solanaDAppStore + case samsungStore + case apkUniversal +} diff --git a/core b/core index 05a092db..939fdb35 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 05a092dbea584813198aaf43e08cfd4833ae9be9 +Subproject commit 939fdb35da0775bddce4c558b16b5860d4c684e4