summaryrefslogtreecommitdiffhomepage
path: root/ios
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-04-02 13:18:39 +0200
committerAndrej Mihajlov <and@mullvad.net>2020-04-02 13:18:39 +0200
commit7ca44f805a4ed113663fcddd8a2d30c6be475f24 (patch)
treeb6a44a713f87b213ffc1ba5b7b554e8e26ec4c80 /ios
parent11a4a71e7dfce7f613408d83a0285ad1fac51972 (diff)
downloadmullvadvpn-7ca44f805a4ed113663fcddd8a2d30c6be475f24.tar.xz
mullvadvpn-7ca44f805a4ed113663fcddd8a2d30c6be475f24.zip
Change to using the non-renewable subscriptions and move the subscription title into the code
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