From 312eade2cd8af5c477cc17a86176894a3ff5ff87 Mon Sep 17 00:00:00 2001 From: Michal Smaga Date: Mon, 1 Jul 2024 00:10:49 +0200 Subject: [PATCH] Remove Privacy Pro from device once expired account is deleted (#3009) Task/Issue URL: https://app.asana.com/0/1200019156869587/1207492658883345/f Description: When fetching subscription info a 401 response means that the token is no longer valid. As a result we should sign out the user. --- DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- DuckDuckGo/AppDelegate.swift | 15 ++++++--------- .../Subscription/SubscriptionManageriOS14.swift | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 5634ff679d..9100bddd30 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -9858,7 +9858,7 @@ repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 163.0.1; + version = 164.0.0; }; }; 9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 10fe30f9f2..11bfbd9a1b 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/DuckDuckGo/BrowserServicesKit", "state" : { - "revision" : "39e10c8eeddeb03750350597bd55fd8c43b5fd83", - "version" : "163.0.1" + "revision" : "be669f88c20b862b43e6267004c45022447209ee", + "version" : "164.0.0" } }, { diff --git a/DuckDuckGo/AppDelegate.swift b/DuckDuckGo/AppDelegate.swift index 6baea32fd5..d33015d5df 100644 --- a/DuckDuckGo/AppDelegate.swift +++ b/DuckDuckGo/AppDelegate.swift @@ -462,6 +462,7 @@ import WebKit } } + // swiftlint:disable:next function_body_length func applicationDidBecomeActive(_ application: UIApplication) { guard !testing else { return } @@ -525,7 +526,11 @@ import WebKit } #endif - updateSubscriptionStatus() + AppDependencyProvider.shared.subscriptionManager.refreshCachedSubscriptionAndEntitlements { isSubscriptionActive in + if isSubscriptionActive { + DailyPixel.fire(pixel: .privacyProSubscriptionActive) + } + } let importPasswordsStatusHandler = ImportPasswordsStatusHandler(syncService: syncService) importPasswordsStatusHandler.checkSyncSuccessStatus() @@ -552,14 +557,6 @@ import WebKit await AppDependencyProvider.shared.networkProtectionTunnelController.removeVPN() } - func updateSubscriptionStatus() { - AppDependencyProvider.shared.subscriptionManager.updateSubscriptionStatus { isActive in - if isActive { - DailyPixel.fire(pixel: .privacyProSubscriptionActive) - } - } - } - func applicationWillResignActive(_ application: UIApplication) { Task { await refreshShortcuts() diff --git a/DuckDuckGo/Subscription/SubscriptionManageriOS14.swift b/DuckDuckGo/Subscription/SubscriptionManageriOS14.swift index b909855ae6..684ea20a41 100644 --- a/DuckDuckGo/Subscription/SubscriptionManageriOS14.swift +++ b/DuckDuckGo/Subscription/SubscriptionManageriOS14.swift @@ -32,7 +32,7 @@ class SubscriptionManageriOS14: SubscriptionManager { var currentEnvironment: SubscriptionEnvironment = SubscriptionEnvironment.default var canPurchase: Bool = false func loadInitialData() {} - func updateSubscriptionStatus(completion: @escaping (Bool) -> Void) {} + func refreshCachedSubscriptionAndEntitlements(completion: @escaping (Bool) -> Void) {} func url(for type: SubscriptionURL) -> URL { URL(string: "https://duckduckgo.com")!