Here's the code. It works on iOS/iPadOS but not macOS for the same .storekit file???
import SwiftUI
import StoreKit
public enum License: String, CaseIterable, Identifiable {
public var id: String { self.rawValue }
case subscriptionLifetimePremium = "subscription.lifetime"
case subscriptionYearlyPremium = "subscription.yearly"
case subscriptionMonthlyPremium = "subscription.monthly"
}
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Button("StoreKit Test") {
Task { @MainActor in
// Request our offers from the app store
let productIDs = License.allCases.map { $0.rawValue }
print("productIDs: \(productIDs)")
let productsOffered = try await Product.products(for: Set(productIDs))
print("productsOffered: \(productsOffered)")
}
}
}
.padding()
}
}```
Topic:
App & System Services
SubTopic:
StoreKit
Tags: