summaryrefslogtreecommitdiffhomepage
path: root/ios
diff options
context:
space:
mode:
Diffstat (limited to 'ios')
-rw-r--r--ios/MullvadVPN/AccountViewController.swift10
-rw-r--r--ios/MullvadVPN/AppStorePaymentManager.swift23
2 files changed, 26 insertions, 7 deletions
diff --git a/ios/MullvadVPN/AccountViewController.swift b/ios/MullvadVPN/AccountViewController.swift
index 2e78e74448..cb216947d5 100644
--- a/ios/MullvadVPN/AccountViewController.swift
+++ b/ios/MullvadVPN/AccountViewController.swift
@@ -110,9 +110,15 @@ class AccountViewController: UIViewController {
private func setProduct(_ product: SKProduct, animated: Bool) {
self.product = product
+ let localizedTitle = product.customLocalizedTitle ?? ""
let localizedPrice = product.localizedPrice ?? ""
- let title = String(format: NSLocalizedString("%@ (%@)", comment: ""),
- product.localizedTitle, localizedPrice)
+
+ let format = NSLocalizedString(
+ "%1$@ (%2$@)",
+ comment: "The buy button title: <TITLE> (<PRICE>). The order can be changed by swapping %1 and %2."
+ )
+ let title = String(format: format, localizedTitle, localizedPrice)
+
purchaseButton.setTitle(title, for: .normal)
}
diff --git a/ios/MullvadVPN/AppStorePaymentManager.swift b/ios/MullvadVPN/AppStorePaymentManager.swift
index 7fada5ca67..7addb58d52 100644
--- a/ios/MullvadVPN/AppStorePaymentManager.swift
+++ b/ios/MullvadVPN/AppStorePaymentManager.swift
@@ -11,12 +11,25 @@ import Foundation
import StoreKit
import os
-enum InAppPurchase: String {
- /// Thirty days worth of credit
- case thirtyDays = "net.mullvad.MullvadVPN.iap.30days"
+enum AppStoreSubscription: String {
+ /// Thirty days non-renewable subscription
+ case thirtyDays = "net.mullvad.MullvadVPN.subscription.30days"
+
+ var localizedTitle: String {
+ switch self {
+ case .thirtyDays:
+ return NSLocalizedString("Add 30 days time", comment: "")
+ }
+ }
+}
+
+extension SKProduct {
+ var customLocalizedTitle: String? {
+ return AppStoreSubscription(rawValue: productIdentifier)?.localizedTitle
+ }
}
-extension Set where Element == InAppPurchase {
+extension Set where Element == AppStoreSubscription {
var productIdentifiersSet: Set<String> {
Set<String>(self.map { $0.rawValue })
}
@@ -179,7 +192,7 @@ class AppStorePaymentManager {
// MARK: - Products and payments
- func requestProducts(with productIdentifiers: Set<InAppPurchase>)
+ func requestProducts(with productIdentifiers: Set<AppStoreSubscription>)
-> SKRequestPublisher<SKProductsRequestSubscription>
{
let productIdentifiers = productIdentifiers.productIdentifiersSet