Skip to content

Commit

Permalink
Additional Privacy Pro RMF changes (#2911)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/414235014887631/1207409447873013/f
Tech Design URL:
CC:

Description:

This PR adds support for new RMF attributes and placeholder image for Privacy Pro.
  • Loading branch information
samsymons authored Jun 3, 2024
1 parent c642979 commit 04106bf
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9778,7 +9778,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 149.0.0;
version = 150.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" : "cd7850dd115f4c896095f410c1049fc32bdf7b16",
"version" : "149.0.0"
"revision" : "03e6b719671c5baaa2afa474d447b707bf595820",
"version" : "150.0.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"images" : [
{
"filename" : "RemoteMessageVPNAnnounce.pdf",
"filename" : "RemoteMessagePrivacyPro.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
Binary file not shown.
18 changes: 17 additions & 1 deletion DuckDuckGo/RemoteMessaging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@ struct RemoteMessaging {
let daysSinceNetworkProtectionEnabled = activationDateStore.daysSinceActivation() ?? -1
let surveyActionMapper = DefaultRemoteMessagingSurveyURLBuilder(statisticsStore: statisticsStore)

var privacyProDaysSinceSubscribed: Int = -1
var privacyProDaysUntilExpiry: Int = -1

if let accessToken = AppDependencyProvider.shared.subscriptionManager.accountManager.accessToken {
let subscriptionResult = await AppDependencyProvider.shared.subscriptionManager.subscriptionService.getSubscription(
accessToken: accessToken
)

if case let .success(subscription) = subscriptionResult {
privacyProDaysSinceSubscribed = Calendar.current.numberOfDaysBetween(subscription.startedAt, and: Date()) ?? -1
privacyProDaysUntilExpiry = Calendar.current.numberOfDaysBetween(Date(), and: subscription.expiresOrRenewsAt) ?? -1
}
}

let remoteMessagingConfigMatcher = RemoteMessagingConfigMatcher(
appAttributeMatcher: AppAttributeMatcher(statisticsStore: statisticsStore,
variantManager: variantManager,
Expand All @@ -173,7 +187,9 @@ struct RemoteMessaging {
isWidgetInstalled: isWidgetInstalled,
daysSinceNetPEnabled: daysSinceNetworkProtectionEnabled,
isPrivacyProEligibleUser: canPurchase,
isPrivacyProSubscriber: isPrivacyProSubscriber),
isPrivacyProSubscriber: isPrivacyProSubscriber,
privacyProDaysSinceSubscribed: privacyProDaysSinceSubscribed,
privacyProDaysUntilExpiry: privacyProDaysUntilExpiry),
percentileStore: RemoteMessagingPercentileUserDefaultsStore(userDefaults: .standard),
surveyActionMapper: surveyActionMapper,
dismissedMessageIds: remoteMessagingStore.fetchDismissedRemoteMessageIds()
Expand Down
4 changes: 3 additions & 1 deletion DuckDuckGoTests/RemoteMessagingStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ class RemoteMessagingStoreTests: XCTestCase {
isWidgetInstalled: false,
daysSinceNetPEnabled: -1,
isPrivacyProEligibleUser: false,
isPrivacyProSubscriber: false),
isPrivacyProSubscriber: false,
privacyProDaysSinceSubscribed: -1,
privacyProDaysUntilExpiry: -1),
percentileStore: RemoteMessagingPercentileUserDefaultsStore(userDefaults: self.defaults),
surveyActionMapper: MockRemoteMessagingSurveyActionMapper(),
dismissedMessageIds: []
Expand Down

0 comments on commit 04106bf

Please sign in to comment.