Error thrown when querying for Subscription Products

Hi, I have been testing StoreKit 2. I'm trying to query for available subscription products by using the following query code as per the document. I have configured the in-app purchases with subscriptions in appstoreconnect. The request query keeps throwing an error.

Would appreciate some help.

Query Code

let productIdentifiers: Set = ["monthly_subscription", "yearly_subscription", "family_monthly_subscription", "family_yearly_subscription"]

        async {

            do {

                let _subscribableProducts = try await Product.request(with: productIdentifiers)

                self.subscribableProducts = _subscribableProducts
            }

            catch {

                print("Something went wronge \(error)")
            }
        }

Error thrown

systemError(Error Domain=ASDErrorDomain Code=507 "Error decoding response" UserInfo={NSLocalizedDescription=Error decoding response, NSLocalizedFailureReason=Could not decode media products response})

The code snippet you posted is the correct way to use this API. Could you run the code again, and then file Feedback including a sysdiagnose from the device the code is running on so we can take a closer look?

Hi, thanks for the quick reply.

I have the sysdiagnose of the iOS simulator used for testing the app. The file I got is a zip file. But I'm not able to upload the zip file. I'd like to know, which specific file from unzipped file is required for diagnosis.

Regards, Pradeep.

In Beta 1 there is a known issue where StoreKit 2 product requests will not work when using the simulator targeted at the Sandbox environment. To work around this, you can use StoreKit Testing in Xcode with either a real device or a simulator. You can also use the Sandbox environment with a real device, which is expected to work in Beta 1.

Thanks, Looking forward to upcoming updates for testing them on the simulator.

Hi there, I have been working on StoreKit 2 for my app. I'm still facing the issue with simulators even after updating to the released version of Xcode 13 and its simulators. It's been working correctly on a device.

Below is the query code:

let productIdentifiers: Set = ["monthly_subscription", "yearly_subscription", "family_monthly_subscription", "family_yearly_subscription"]

        

        Task(priority: nil){

            do {

                let _subscribableProducts = try await Product.products(for: productIdentifiers)

                

                /**/

                self.subscribableProducts = _subscribableProducts

                /**/

                

                for subscriptionProduct in self.subscribableProducts {

                    

                    let model_Subscribe = Model_SubscribeType(subscribeType: subscriptionProduct.id, subscribeKey: subscriptionProduct.id, subscribeDuration: "", subscribe_CostCurrency: String(subscriptionProduct.displayPrice.prefix(1)), subscribe_Cost: "\(subscriptionProduct.price)", subscribe_DisplayPrice: subscriptionProduct.displayPrice, subscribe_isSubscribed: false, subscribe_FamilySharing: subscriptionProduct.isFamilyShareable, subscribe_SKProduct: subscriptionProduct)

                    

                    self.subscriptionProducts.append(model_Subscribe)


                }

                

                self.delegate.updateSubscriptionProductList(subscriptionProducts: self.subscriptionProducts)

                /**/

                

            }

            catch {

                print("Something went wrong \(error.localizedDescription)")

                switch error {

                case StoreKitError.unknown:

                    print("StoreKitError.unknown")

                case StoreKitError.userCancelled:

                    print("StoreKitError.userCancelled")

                case StoreKitError.networkError(let network_error):

                    print("StoreKitError.networkError: \(network_error)")

                case StoreKitError.systemError(let system_error):

                    print("StoreKitError.systemError: \(system_error)")

                default:

                    print("StoreKitError.default")

                }

            }

            

        }

The following are the errors thrown when querying for products from StoreKit on a Simulator:

1:

[Default] [StoreKit] Failed to get products through appstored in simulator, will try using appstoreagent on host mac:

Error Domain=ASDErrorDomain Code=507 "Error decoding response" UserInfo={NSLocalizedDescription=Error decoding response, NSLocalizedFailureReason=Could not decode media products response}

2:

[Default] Failed in XPC product request ["family_yearly_subscription", "monthly_subscription", "family_monthly_subscription", "yearly_subscription"]: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.storekitservice.sim2host was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.storekitservice.sim2host was invalidated: failed at lookup with error 3 - No such process.}

3:

Something went wrong The operation couldn’t be completed. (StoreKit.StoreKitError error 1.)

StoreKitError.systemError: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.storekitservice.sim2host was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.storekitservice.sim2host was invalidated: failed at lookup with error 3 - No such process.}

Would really appreciate some resolution for this. It's been frustrating to consistently work without a simulator for this.

Regards, Pradeep.

When targeting the sandbox environment, the Product.products(for:) method is only supported in simulators when you are running Xcode 13 on macOS 12 Beta 4 or newer.

If your Mac is not running macOS 12, you can still use Product.products(for:) in the simulator using the Xcode environment. Using a real device is supported in either environment, regardless of the macOS version you are running Xcode on.

I was running in to this issue as well. For every simulator I was testing I had to re-enable the Store Kit Configuration in Edit Scheme.

Error thrown when querying for Subscription Products
 
 
Q