Skip to content

Commit

Permalink
Remove Privacy Pro from device once expired account is deleted (#3009)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
miasma13 authored Jun 30, 2024
1 parent 23f26ab commit 312eade
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
15 changes: 6 additions & 9 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ import WebKit
}
}

// swiftlint:disable:next function_body_length
func applicationDidBecomeActive(_ application: UIApplication) {
guard !testing else { return }

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Subscription/SubscriptionManageriOS14.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")!
Expand Down

0 comments on commit 312eade

Please sign in to comment.