From 583baa15282f10d05cf8f9cdeb071f9ac0e12e1f Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Mon, 18 Nov 2024 16:41:17 +0100 Subject: [PATCH 1/2] Limits TipKit availability to iOS 18+ --- DuckDuckGo/NetworkProtectionStatusView.swift | 12 +++++----- .../TipKit/TipKitAppEventHandling.swift | 24 +++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/DuckDuckGo/NetworkProtectionStatusView.swift b/DuckDuckGo/NetworkProtectionStatusView.swift index 21e79aa654..90196e3846 100644 --- a/DuckDuckGo/NetworkProtectionStatusView.swift +++ b/DuckDuckGo/NetworkProtectionStatusView.swift @@ -148,13 +148,13 @@ struct NetworkProtectionStatusView: View { .listRowBackground(Color(designSystemColor: .surface)) Section { - if #available(iOS 17.0, *) { + if #available(iOS 18.0, *) { widgetTipView() .tipImageSize(Self.defaultImageSize) .padding(.horizontal, 3) } - if #available(iOS 17.0, *) { + if #available(iOS 18.0, *) { snoozeTipView() .tipImageSize(Self.defaultImageSize) .padding(.horizontal, 3) @@ -256,7 +256,7 @@ struct NetworkProtectionStatusView: View { .listRowBackground(Color(designSystemColor: .surface)) Section { - if #available(iOS 17.0, *) { + if #available(iOS 17.8, *) { geoswitchingTipView() .tipImageSize(Self.defaultImageSize) .padding(.horizontal, 3) @@ -351,7 +351,7 @@ struct NetworkProtectionStatusView: View { // MARK: - Tips - @available(iOS 17.0, *) + @available(iOS 18.0, *) @ViewBuilder private func geoswitchingTipView() -> some View { if statusModel.canShowTips { @@ -363,7 +363,7 @@ struct NetworkProtectionStatusView: View { } } - @available(iOS 17.0, *) + @available(iOS 18.0, *) @ViewBuilder private func snoozeTipView() -> some View { if statusModel.canShowTips, @@ -376,7 +376,7 @@ struct NetworkProtectionStatusView: View { } } - @available(iOS 17.0, *) + @available(iOS 18.0, *) @ViewBuilder private func widgetTipView() -> some View { if statusModel.canShowTips, diff --git a/DuckDuckGo/TipKit/TipKitAppEventHandling.swift b/DuckDuckGo/TipKit/TipKitAppEventHandling.swift index d747af3fd4..1fb5e851bc 100644 --- a/DuckDuckGo/TipKit/TipKitAppEventHandling.swift +++ b/DuckDuckGo/TipKit/TipKitAppEventHandling.swift @@ -18,6 +18,7 @@ // import Core +import BrowserServicesKit import Foundation import os.log @@ -28,26 +29,29 @@ protocol TipKitAppEventHandling { struct TipKitAppEventHandler: TipKitAppEventHandling { private let controller: TipKitController + private let featureFlagger: FeatureFlagger private let logger: Logger init(controller: TipKitController = .make(), + featureFlagger: FeatureFlagger = AppDependencyProvider.shared.featureFlagger, logger: Logger = .tipKit) { self.controller = controller + self.featureFlagger = featureFlagger self.logger = logger } func appDidFinishLaunching() { - if #available(iOS 17.0, *) { - // TipKit is temporarily disabled. - // See https://app.asana.com/0/inbox/1203108348814444/1208724397684354/1208739407931826 - // for more information - logger.log("TipKit is temporarily disabled.") - - // controller.configureTipKit([ - // .displayFrequency(.immediate), - // .datastoreLocation(.applicationDefault) - // ]) + guard featureFlagger.isFeatureOn(.networkProtectionUserTips) else { + logger.log("TipKit disabled by remote feature flag.") + return + } + + if #available(iOS 18.0, *) { + controller.configureTipKit([ + .displayFrequency(.immediate), + .datastoreLocation(.applicationDefault) + ]) } else { logger.log("TipKit initialization skipped: iOS 17.0 or later is required.") } From c420755214f2e379bca1cb4540d44ca5810087c9 Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Tue, 19 Nov 2024 10:28:23 +0100 Subject: [PATCH 2/2] Fixed an OS version guard --- DuckDuckGo/NetworkProtectionStatusView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DuckDuckGo/NetworkProtectionStatusView.swift b/DuckDuckGo/NetworkProtectionStatusView.swift index 90196e3846..88e6768dea 100644 --- a/DuckDuckGo/NetworkProtectionStatusView.swift +++ b/DuckDuckGo/NetworkProtectionStatusView.swift @@ -256,7 +256,7 @@ struct NetworkProtectionStatusView: View { .listRowBackground(Color(designSystemColor: .surface)) Section { - if #available(iOS 17.8, *) { + if #available(iOS 18.0, *) { geoswitchingTipView() .tipImageSize(Self.defaultImageSize) .padding(.horizontal, 3)