Przeglądaj źródła

fix(iap): stop showing hardcoded paywall prices before StoreKit loads

Use localized Product.displayPrice only; show an em dash until products are available.
Document ASC-safe product ID rules and keeping IDs in sync across code and StoreKit config.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 3 tygodni temu
rodzic
commit
3c71d5b75e

+ 9 - 7
App for Indeed/Controllers/PremiumPlansWindowController.swift

@@ -356,11 +356,13 @@ private final class PremiumPlansViewController: NSViewController {
356 356
         }
357 357
     }
358 358
 
359
+    /// Shown until StoreKit returns localized `Product.displayPrice` (never use hardcoded currency amounts).
360
+    private static let unloadedPricePlaceholder = "—"
361
+
359 362
     private struct Plan {
360 363
         let id: String
361 364
         let title: String
362 365
         let subtitle: String
363
-        let price: String
364 366
         let period: String
365 367
         let billedPill: String
366 368
         let billedLine: String
@@ -405,7 +407,6 @@ private final class PremiumPlansViewController: NSViewController {
405 407
             id: "weekly",
406 408
             title: "Weekly",
407 409
             subtitle: "Flexible and commitment-free",
408
-            price: "$9.99",
409 410
             period: "/ week",
410 411
             billedPill: "",
411 412
             billedLine: "",
@@ -424,7 +425,6 @@ private final class PremiumPlansViewController: NSViewController {
424 425
             id: "monthly",
425 426
             title: "Monthly",
426 427
             subtitle: "Balanced for regular productivity",
427
-            price: "$19.99",
428 428
             period: "/ month",
429 429
             billedPill: "",
430 430
             billedLine: "",
@@ -443,7 +443,6 @@ private final class PremiumPlansViewController: NSViewController {
443 443
             id: "yearly",
444 444
             title: "Yearly",
445 445
             subtitle: "Best value for long-term users",
446
-            price: "$39.99",
447 446
             period: "/ year",
448 447
             billedPill: "3 days free trial",
449 448
             billedLine: "",
@@ -603,7 +602,7 @@ private final class PremiumPlansViewController: NSViewController {
603 602
         topRightTag.isHidden = plan.billedPill.isEmpty
604 603
         topRightTag.font = .systemFont(ofSize: 10, weight: .bold)
605 604
 
606
-        let priceLabel = NSTextField(labelWithString: plan.price)
605
+        let priceLabel = NSTextField(labelWithString: Self.unloadedPricePlaceholder)
607 606
         priceLabel.font = .systemFont(ofSize: 18, weight: .semibold)
608 607
         priceLabel.textColor = Theme.primaryText
609 608
 
@@ -931,8 +930,11 @@ private final class PremiumPlansViewController: NSViewController {
931 930
 
932 931
     private func applyStorePricing() {
933 932
         for plan in plans {
934
-            guard let fields = planPriceFields[plan.id],
935
-                  let product = subscriptionStore.product(forPlanKey: plan.id) else { continue }
933
+            guard let fields = planPriceFields[plan.id] else { continue }
934
+            guard let product = subscriptionStore.product(forPlanKey: plan.id) else {
935
+                fields.price.stringValue = Self.unloadedPricePlaceholder
936
+                continue
937
+            }
936 938
             fields.price.stringValue = product.displayPrice
937 939
             if let period = product.subscription?.subscriptionPeriod {
938 940
                 fields.period.stringValue = periodSuffix(for: period)

+ 3 - 2
App for Indeed/Subscription/SubscriptionProductIDs.swift

@@ -6,8 +6,9 @@
6 6
 import Foundation
7 7
 
8 8
 /// Identifiers for auto-renewable subscriptions in App Store Connect.
9
-/// Local Xcode runs use `App for Indeed/ProSubscriptions.storekit` (selected in the Run scheme → Options → StoreKit Configuration).
10
-/// Create three subscriptions with these exact IDs and attach them to the same subscription group.
9
+/// IDs may only contain letters, numbers, underscores, and periods (no hyphens).
10
+/// Keep these strings identical in code, `ProSubscriptions.storekit`, and App Store Connect.
11
+/// Local Xcode runs use `App for Indeed/ProSubscriptions.storekit` (Run scheme → Options → StoreKit Configuration).
11 12
 enum SubscriptionProductIDs {
12 13
     static let weekly = "com.mqldev.appforindeed.pro.weekly"
13 14
     static let monthly = "com.mqldev.appforindeed.pro.monthly"