diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 700acf7942..a3b99c5410 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -9770,7 +9770,7 @@ repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 153.0.0; + version = "153.0.0-1"; }; }; 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 d43793703e..fb68f5e920 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" : "b78ae617c7fe66244741f489158a1f40e567e674", - "version" : "153.0.0" + "revision" : "aadce5cb02cdbf0b3dbbe846bca997abf1506dbe", + "version" : "153.0.0-1" } }, { diff --git a/DuckDuckGo/RemoteMessaging.swift b/DuckDuckGo/RemoteMessaging.swift index 7dcd862ab4..c1245a6e0e 100644 --- a/DuckDuckGo/RemoteMessaging.swift +++ b/DuckDuckGo/RemoteMessaging.swift @@ -163,6 +163,10 @@ struct RemoteMessaging { var privacyProDaysSinceSubscribed: Int = -1 var privacyProDaysUntilExpiry: Int = -1 + var privacyProPurchasePlatform: String? + var privacyProIsActive: Bool = false + var privacyProIsExpiring: Bool = false + var privacyProIsExpired: Bool = false let surveyActionMapper: DefaultRemoteMessagingSurveyURLBuilder if let accessToken = AppDependencyProvider.shared.subscriptionManager.accountManager.accessToken { @@ -173,6 +177,20 @@ struct RemoteMessaging { if case let .success(subscription) = subscriptionResult { privacyProDaysSinceSubscribed = Calendar.current.numberOfDaysBetween(subscription.startedAt, and: Date()) ?? -1 privacyProDaysUntilExpiry = Calendar.current.numberOfDaysBetween(Date(), and: subscription.expiresOrRenewsAt) ?? -1 + privacyProPurchasePlatform = subscription.platform.rawValue + + switch subscription.status { + case .autoRenewable, .gracePeriod: + privacyProIsActive = true + case .notAutoRenewable: + privacyProIsActive = true + privacyProIsExpiring = true + case .expired, .inactive: + privacyProIsExpired = true + case .unknown: + break // Not supported in RMF + } + surveyActionMapper = DefaultRemoteMessagingSurveyURLBuilder(statisticsStore: statisticsStore, subscription: subscription) } else { surveyActionMapper = DefaultRemoteMessagingSurveyURLBuilder(statisticsStore: statisticsStore, subscription: nil) @@ -195,7 +213,11 @@ struct RemoteMessaging { isPrivacyProEligibleUser: canPurchase, isPrivacyProSubscriber: isPrivacyProSubscriber, privacyProDaysSinceSubscribed: privacyProDaysSinceSubscribed, - privacyProDaysUntilExpiry: privacyProDaysUntilExpiry), + privacyProDaysUntilExpiry: privacyProDaysUntilExpiry, + privacyProPurchasePlatform: privacyProPurchasePlatform, + isPrivacyProSubscriptionActive: privacyProIsActive, + isPrivacyProSubscriptionExpiring: privacyProIsExpiring, + isPrivacyProSubscriptionExpired: privacyProIsExpired), percentileStore: RemoteMessagingPercentileUserDefaultsStore(userDefaults: .standard), surveyActionMapper: surveyActionMapper, dismissedMessageIds: remoteMessagingStore.fetchDismissedRemoteMessageIds() diff --git a/DuckDuckGoTests/RemoteMessagingStoreTests.swift b/DuckDuckGoTests/RemoteMessagingStoreTests.swift index ecf4c0edb7..14c2f59ce5 100644 --- a/DuckDuckGoTests/RemoteMessagingStoreTests.swift +++ b/DuckDuckGoTests/RemoteMessagingStoreTests.swift @@ -145,7 +145,11 @@ class RemoteMessagingStoreTests: XCTestCase { isPrivacyProEligibleUser: false, isPrivacyProSubscriber: false, privacyProDaysSinceSubscribed: -1, - privacyProDaysUntilExpiry: -1), + privacyProDaysUntilExpiry: -1, + privacyProPurchasePlatform: nil, + isPrivacyProSubscriptionActive: false, + isPrivacyProSubscriptionExpiring: false, + isPrivacyProSubscriptionExpired: false), percentileStore: RemoteMessagingPercentileUserDefaultsStore(userDefaults: self.defaults), surveyActionMapper: MockRemoteMessagingSurveyActionMapper(), dismissedMessageIds: []