Skip to content

Commit caffb40

Browse files
committed
Add localized error message for paymentNotAllowed SKError
1 parent c5a81b4 commit caffb40

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

Cryptomator/Purchase/IAPViewController.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ class BaseIAPViewModel {
226226
return iapManager.buy(product).recover { error -> PurchaseTransaction in
227227
if (error as? SKError)?.code == .paymentCancelled {
228228
throw PurchaseError.paymentCancelled
229+
} else if (error as? SKError)?.code == .paymentNotAllowed {
230+
throw PurchaseError.paymentNotAllowed
229231
} else if (error as? SKError)?.code == .unknown {
230232
throw PurchaseError.unknown
231233
} else {
@@ -279,6 +281,8 @@ class BaseIAPViewModel {
279281
return iapManager.restore().recover { error -> RestoreTransactionsResult in
280282
if (error as? SKError)?.code == .paymentCancelled {
281283
throw PurchaseError.paymentCancelled
284+
} else if (error as? SKError)?.code == .paymentNotAllowed {
285+
throw PurchaseError.paymentNotAllowed
282286
} else if (error as? SKError)?.code == .unknown {
283287
throw PurchaseError.unknown
284288
} else {

Cryptomator/Purchase/PurchaseViewModel.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import StoreKit
1414
enum PurchaseError: LocalizedError {
1515
case unavailableProduct
1616
case paymentCancelled
17+
case paymentNotAllowed
1718
case unknown
1819

1920
var errorDescription: String? {
@@ -22,6 +23,8 @@ enum PurchaseError: LocalizedError {
2223
return nil // should never happen
2324
case .paymentCancelled:
2425
return nil // not needed since nothing should be shown
26+
case .paymentNotAllowed:
27+
return LocalizedString.getValue("purchase.error.paymentNotAllowed")
2528
case .unknown:
2629
return LocalizedString.getValue("purchase.error.unknown")
2730
}

SharedResources/en.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
"purchase.title" = "Unlock Full Version";
198198
"purchase.unlockedFullVersion.message" = "You can now use the full version of Cryptomator. Happy crypting!";
199199
"purchase.unlockedFullVersion.title" = "Thank You";
200+
"purchase.error.paymentNotAllowed" = "In-app purchases are not allowed on this device. Please check your Screen Time settings under Content & Privacy Restrictions to enable purchases.";
200201
"purchase.error.unknown" = "This purchase is unavailable in the App Store for an unknown reason. Please try again later.\n\nIf this error persists, try to restart your device or signing out and back in to your Apple ID in the iOS settings.";
201202

202203
"settings.title" = "Settings";

0 commit comments

Comments
 (0)