Skip to content

Commit

Permalink
Merge branch 'jkb/fix/VPNAPPL-2229-remove-old-iap' into 'develop'
Browse files Browse the repository at this point in the history
Merge-Request: apple/vpn/protonvpn!1997
Approved-by: Chris Janusiewicz <[email protected]>
  • Loading branch information
protonjohn committed Sep 26, 2024
2 parents b8bef92 + 42bca43 commit bc5c737
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 550 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "external/protoncore"]
path = external/protoncore
url = ../../shared/protoncore
tag = 26.1.0
tag = 26.3.1
[submodule "external/apple-fusion"]
path = external/apple-fusion
url = ../../../tpe/apple-fusion
Expand Down
8 changes: 4 additions & 4 deletions ProtonVPN.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@
"repositoryURL": "https://github.com/getsentry/sentry-cocoa",
"state": {
"branch": null,
"revision": "c9a692ba837f4832ec7ce6378c071cb91cb55f92",
"version": "8.29.0"
"revision": "5575af93efb776414f243e93d6af9f6258dc539a",
"version": "8.36.0"
}
},
{
Expand Down Expand Up @@ -366,8 +366,8 @@
"repositoryURL": "https://github.com/nalexn/ViewInspector.git",
"state": {
"branch": null,
"revision": "7b1732802ffe30e6a67754bda6c7819e5cb0eb70",
"version": "0.9.11"
"revision": "5acfa0a3c095ac9ad050abe51c60d1831e8321da",
"version": "0.10.0"
}
},
{
Expand Down
86 changes: 26 additions & 60 deletions apps/ios/ProtonVPN/Scenes/Common/Services/IosAlertService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -327,31 +327,33 @@ extension IosAlertService: CoreAlertService {
}

private func show(alert: UpsellAlert, modalType: Modals.ModalType) {
let viewController: UIViewController
do {
let oneClickPayment = try OneClickPayment(alertService: self, planService: planService, payments: planService.payments)
oneClickPayment.completionHandler = { [weak self] in
self?.windowService.dismissModal(nil)
}
viewController = modalsFactory.upsellViewController(
modalType: modalType,
client: oneClickPayment.plansClient(
validationHandler: {
NotificationCenter.default.post(name: .userEngagedWithUpsellAlert, object: alert.modalSource)
},
notNowHandler: { [weak self] in
self?.windowService.dismissModal(nil)
}
)
)
viewController.modalPresentationStyle = .overFullScreen
self.oneClickPayment = oneClickPayment
} catch {
let upsellViewController = modalsFactory.upsellViewController(modalType: modalType)
upsellViewController.delegate = self
upsellAlerts[upsellViewController.id] = alert
viewController = upsellViewController
guard let oneClickPayment = OneClickPayment(
alertService: self,
planService: planService,
payments: planService.payments
) else {
// Can be disabled if `DynamicPlan` FF set to false, but this doesn't happen in practice (default is true).
return
}

oneClickPayment.completionHandler = { [weak self] in
self?.windowService.dismissModal(nil)
}

let viewController = modalsFactory.upsellViewController(
modalType: modalType,
client: oneClickPayment.plansClient(
validationHandler: {
NotificationCenter.default.post(name: .userEngagedWithUpsellAlert, object: alert.modalSource)
},
notNowHandler: { [weak self] in
self?.windowService.dismissModal(nil)
}
)
)
viewController.modalPresentationStyle = .overFullScreen
self.oneClickPayment = oneClickPayment

windowService.present(modal: viewController)
NotificationCenter.default.post(name: .upsellAlertWasDisplayed, object: alert.modalSource)
}
Expand Down Expand Up @@ -457,42 +459,6 @@ extension IosAlertService: CoreAlertService {
}
}

extension IosAlertService: UpsellViewControllerDelegate {
func shouldDismissUpsell(upsell: UpsellViewController?) -> Bool {
return true
}

func userDidRequestPlus(upsell: UpsellViewController?) {
// Hold onto alert reference before its removed from `upsellAlerts` on disappear
var modalSource: UpsellEvent.ModalSource?
if let upsell, let alert = upsellAlerts[upsell.id] {
modalSource = alert.modalSource
NotificationCenter.default.post(name: .userEngagedWithUpsellAlert, object: modalSource)
}

windowService.dismissModal { [weak self] in
self?.planService.presentPlanSelection(modalSource: modalSource)
}
}

func userDidDismissUpsell(upsell: UpsellViewController?) {
windowService.dismissModal { }
}

func userDidTapNext(upsell: UpsellViewController) {
let alert = upsellAlerts[upsell.id] // Hold onto alert reference before its removed from `upsellAlerts` on disappear
windowService.dismissModal { [alert] in
alert?.continueAction()
}
}

func upsellDidDisappear(upsell: UpsellViewController?) {
if let id = upsell?.id {
upsellAlerts.removeValue(forKey: id)
}
}
}

fileprivate extension ReconnectInfo {
func servers() -> (from: (String, Image), to: (String, Image)) {
((fromServer.name, fromServer.image), (toServer.name, toServer.image))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,25 @@ extension OnboardingModuleService: OnboardingService {
}

func welcomeToProtonPrimaryAction() {
let viewController: UIViewController
do {
let oneClickPayment = try OneClickPayment(alertService: alertService, planService: planService, payments: planService.payments)
oneClickPayment.completionHandler = { [weak self] in
self?.onboardingCoordinatorDidFinish()
}
viewController = oneClickPayment.oneClickIAPViewController(dismissAction: {
self.windowService.dismissModal {
self.onboardingCoordinatorDidFinish()
}
})
self.oneClickPayment = oneClickPayment
} catch {
log.debug("One click payment disabled: \(error)")
viewController = allCountriesUpsellViewController()
guard let oneClickPayment = OneClickPayment(
alertService: alertService,
planService: planService,
payments: planService.payments
) else {
// Can be disabled if `DynamicPlan` FF set to false, but this doesn't happen in practice (default is true).
return
}

oneClickPayment.completionHandler = { [weak self] in
self?.onboardingCoordinatorDidFinish()
}

let viewController = oneClickPayment.oneClickIAPViewController(dismissAction: {
self.windowService.dismissModal {
self.onboardingCoordinatorDidFinish()
}
})
self.oneClickPayment = oneClickPayment
windowService.addToStack(viewController, checkForDuplicates: false)
}

Expand Down
8 changes: 3 additions & 5 deletions apps/ios/ProtonVPN/Scenes/Payments/OneClickPayment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ final class OneClickPayment {

private var plansClientValue: PlansClient?

init(alertService: CoreAlertService, planService: PlanService, payments: Payments) throws {
guard FeatureFlagsRepository.shared.isEnabled(VPNFeatureFlagType.oneClickPayment) else {
throw "OneClickAIAP FF disabled!" as GenericError
}
init?(alertService: CoreAlertService, planService: PlanService, payments: Payments) {
guard case .right(let plansDataSource) = payments.planService else {
throw "DynamicPlan FF disabled!" as GenericError
log.error("DynamicPlan FF disabled!")
return nil
}
self.plansDataSource = plansDataSource
self.alertService = alertService
Expand Down
28 changes: 14 additions & 14 deletions apps/ios/iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2518,18 +2518,18 @@
mainGroup = 791DE5D0208DDA3000A29EA5;
packageReferences = (
4CB776CB2A1F5E61004CA127 /* XCRemoteSwiftPackageReference "swift-composable-architecture" */,
4CB776D32A1F62DF004CA127 /* XCRemoteSwiftPackageReference "swift-log.git" */,
E5A4AD2A2A3C48B400CC91D7 /* XCRemoteSwiftPackageReference "swift-dependencies.git" */,
4CB776D32A1F62DF004CA127 /* XCRemoteSwiftPackageReference "swift-log" */,
E5A4AD2A2A3C48B400CC91D7 /* XCRemoteSwiftPackageReference "swift-dependencies" */,
ADBA84DD2A58A1A0001EF3F5 /* XCRemoteSwiftPackageReference "swift-case-paths" */,
4C9754F22A6017260035A61B /* XCRemoteSwiftPackageReference "SwiftOTP.git" */,
4C9754F22A6017260035A61B /* XCRemoteSwiftPackageReference "SwiftOTP" */,
4C9754F82A6018040035A61B /* XCRemoteSwiftPackageReference "GSMessages" */,
4C7D404C2A60244C00ACDBED /* XCRemoteSwiftPackageReference "Alamofire" */,
4C7D40542A60250300ACDBED /* XCRemoteSwiftPackageReference "SDWebImage" */,
4C7D405A2A6027C400ACDBED /* XCRemoteSwiftPackageReference "KeychainAccess" */,
4C7D40622A60282D00ACDBED /* XCRemoteSwiftPackageReference "AlamofireImage" */,
4C7D40652A60289400ACDBED /* XCRemoteSwiftPackageReference "OHHTTPStubs" */,
4C7D40722A60297400ACDBED /* XCRemoteSwiftPackageReference "Reachability.swift" */,
E5DEF05D2A7399EC006FC9DC /* XCRemoteSwiftPackageReference "DictionaryCoder.git" */,
4C7D40722A60297400ACDBED /* XCRemoteSwiftPackageReference "Reachability" */,
E5DEF05D2A7399EC006FC9DC /* XCRemoteSwiftPackageReference "DictionaryCoder" */,
4C8C31612A73BB39006AD628 /* XCRemoteSwiftPackageReference "sentry-cocoa" */,
ADB109C92B63144800B3F4D3 /* XCRemoteSwiftPackageReference "TrustKit" */,
);
Expand Down Expand Up @@ -4032,7 +4032,7 @@
version = 9.1.0;
};
};
4C7D40722A60297400ACDBED /* XCRemoteSwiftPackageReference "Reachability.swift" */ = {
4C7D40722A60297400ACDBED /* XCRemoteSwiftPackageReference "Reachability" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/ashleymills/Reachability.swift";
requirement = {
Expand All @@ -4045,10 +4045,10 @@
repositoryURL = "https://github.com/getsentry/sentry-cocoa";
requirement = {
kind = exactVersion;
version = 8.29.0;
version = 8.36.0;
};
};
4C9754F22A6017260035A61B /* XCRemoteSwiftPackageReference "SwiftOTP.git" */ = {
4C9754F22A6017260035A61B /* XCRemoteSwiftPackageReference "SwiftOTP" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/lachlanbell/SwiftOTP.git";
requirement = {
Expand All @@ -4073,7 +4073,7 @@
version = 1.13.1;
};
};
4CB776D32A1F62DF004CA127 /* XCRemoteSwiftPackageReference "swift-log.git" */ = {
4CB776D32A1F62DF004CA127 /* XCRemoteSwiftPackageReference "swift-log" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/apple/swift-log.git";
requirement = {
Expand All @@ -4097,15 +4097,15 @@
version = 1.5.4;
};
};
E5A4AD2A2A3C48B400CC91D7 /* XCRemoteSwiftPackageReference "swift-dependencies.git" */ = {
E5A4AD2A2A3C48B400CC91D7 /* XCRemoteSwiftPackageReference "swift-dependencies" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/pointfreeco/swift-dependencies.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.3.9;
};
};
E5DEF05D2A7399EC006FC9DC /* XCRemoteSwiftPackageReference "DictionaryCoder.git" */ = {
E5DEF05D2A7399EC006FC9DC /* XCRemoteSwiftPackageReference "DictionaryCoder" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/almazrafi/DictionaryCoder.git";
requirement = {
Expand Down Expand Up @@ -4138,7 +4138,7 @@
};
4C4E98342AC1C07E00B7B285 /* DictionaryCoder */ = {
isa = XCSwiftPackageProductDependency;
package = E5DEF05D2A7399EC006FC9DC /* XCRemoteSwiftPackageReference "DictionaryCoder.git" */;
package = E5DEF05D2A7399EC006FC9DC /* XCRemoteSwiftPackageReference "DictionaryCoder" */;
productName = DictionaryCoder;
};
4C7D404D2A60244C00ACDBED /* Alamofire */ = {
Expand Down Expand Up @@ -4182,7 +4182,7 @@
};
4C9754F32A6017260035A61B /* SwiftOTP */ = {
isa = XCSwiftPackageProductDependency;
package = 4C9754F22A6017260035A61B /* XCRemoteSwiftPackageReference "SwiftOTP.git" */;
package = 4C9754F22A6017260035A61B /* XCRemoteSwiftPackageReference "SwiftOTP" */;
productName = SwiftOTP;
};
4C9754F92A6018040035A61B /* GSMessages */ = {
Expand Down Expand Up @@ -4240,7 +4240,7 @@
};
ADE98F212B6306CA00601881 /* Dependencies */ = {
isa = XCSwiftPackageProductDependency;
package = E5A4AD2A2A3C48B400CC91D7 /* XCRemoteSwiftPackageReference "swift-dependencies.git" */;
package = E5A4AD2A2A3C48B400CC91D7 /* XCRemoteSwiftPackageReference "swift-dependencies" */;
productName = Dependencies;
};
ADE98F252B6306D800601881 /* PMLogger */ = {
Expand Down
2 changes: 1 addition & 1 deletion external/protoncore
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ public enum VPNFeatureFlagType: String, FeatureFlagTypeProtocol {
/// evict the previous session UID and associate the key with the current one.
case certificateRefreshForceRenew = "CertificateRefreshForceRenew"

/// Enable and disable the 1-click upsell
case oneClickPayment = "OneClickAIAP"

/// Don't default to IKEv2 during VPN configuration when no VPN provider is available
case noDefaultToIke = "AppleVPNNoDefaultToIKE"

Expand Down
9 changes: 0 additions & 9 deletions libraries/Modals/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,6 @@
"version": "5.15.8"
}
},
{
"package": "Sentry",
"repositoryURL": "https://github.com/getsentry/sentry-cocoa",
"state": {
"branch": null,
"revision": "c9a692ba837f4832ec7ce6378c071cb91cb55f92",
"version": "8.29.0"
}
},
{
"package": "swift-clocks",
"repositoryURL": "https://github.com/pointfreeco/swift-clocks",
Expand Down
9 changes: 0 additions & 9 deletions libraries/Modals/Sources/Modals-iOS/ModalsFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ public final class ModalsFactory {

// MARK: Properties

private lazy var upsellStoryboard: UIStoryboard = {
UIStoryboard(name: "UpsellViewController", bundle: Bundle.module)
}()
private lazy var discourageStoryboard: UIStoryboard = {
UIStoryboard(name: "DiscourageSecureCoreViewController", bundle: Bundle.module)
}()
Expand All @@ -26,12 +23,6 @@ public final class ModalsFactory {
WhatsNewView().hostingController()
}

public func upsellViewController(modalType: ModalType) -> UpsellViewController {
let upsell = self.upsellStoryboard.instantiate(controllerType: UpsellViewController.self)
upsell.modalType = modalType
return upsell
}

public func upsellViewController(
modalType: ModalType,
client: PlansClient,
Expand Down
Loading

0 comments on commit bc5c737

Please sign in to comment.