I am using the StoreKit 2 Product.products() function to get the subscription products:
do {
let product = try await Product.products(for: ["product_id"])
} catch {
print(error)
}
The function throwing the following error:
2023-02-03 13:27:35.426740+0200 AppName[7101:1766595] [Default] [StoreKit:0e9a] Failed to decode Product: countMismatch(for: [StoreKit.Product.Key.attributes, StoreKit.Product.Key.offers, StoreKit.Product.Key.discounts], expected: Range(0..<2), actual: 2)
Would appreciate some help why I get this error and how can I fix it?
Probably because you did not set the duration of the subscription order on appstoreconnect.com. Go to appstoreconnect.com, select your app then under Feature select Subscriptions. Inside the
Group
you should have Subscriptions Order in a table format. Select the order item, On the new page you should see an option forSubscription Duration
. Set it then save. It will probably take about 10-20 minutes to take effect.