Requesting an In App Purchase in iOS 13 fails
Asked Answered
U

4

61

I use SwiftyStoreKit to request In App Purchases and get only this error with iOS 13:

Error: Optional(Error Domain=ASDErrorDomain Code=507 "Error decoding object" UserInfo={NSLocalizedDescription=Error decoding object, NSLocalizedFailureReason=Attempted to decode store response})

I cannot request information about the products, nor make purchases with a sand box account. However, it works fine in iOS 12.1 on my device. It does not work with the iPhone 11 simulator or an actual device with iOS 13.

I have found a lot, that the Xcode 11 GM seed 1 beta simulator had this problem, but have not found a solution yet. I also tested it with the new released Xcode 11 GM seed 2 version, but there was no fix for me.

Does anyone have a solution on how I can request and purchase In App Purchases again with iOS 13 installed?

Urinate answered 20/9, 2019 at 0:21 Comment(8)
Could you please provide the code of how you make purchases? I use Xcode 11 GM seed but didn't get any errors yet.Canonicity
I am seeing the same issues, but using RMStore, which although not maintained, still works fine up to iOS 12.Athenian
Have any progress on this? I'm having a very similar issue.Merchandise
I've tried everything possible to make In App purchases work in the beta version of iOS 13, too. Also my app was rejected by Apple (No action when using the buy button) before the release of iOS 13. Later I was able to test the app with an iPhone 11 and the public version of iOS 13 and everything works fine again. I can't tell what it was all about. I didn't change the code either. The app is now "Waiting for review" again. I'll give you another update if it will be accepted. There are no more errors in the console launching the App with iPhone 11, iOS 13.Urinate
Having the same issue with Xcode 11 release. iOS 13 simulator doesn't load any products with same error message.Myxomatosis
My app has now been accepted by Apple. But I can't tell what caused the error message. The error no longer occurs. Maybe the fix was a simple restart of Xcode or a clean with Shift + Command + K in XcodeUrinate
@TimothyC. Maybe not related but one thing I've noticed during development: If my iOS device has an iOS update waiting to Download & Install then Sandbox in app purchases fail. After updating the process works as usual. Annoying because this is not an obvious cause.Adman
Xcode 13.4.1: same issue with iOS 14 simulator, but SKProductsRequest works fine on the iOS 15 simulator. On some CI machines the iOS 13 simulator fails, but sometimes not.Toxoplasmosis
M
135

Restarting Xcode and simulator did the trick: now my in-app purchases load properly in iOS 13 simulator.

EDIT: This happens in release Xcode 11 too. And happens once in a while, but restarting Xcode and simulators still helps.

EDIT 2: In Xcode 12 beta this bug is also present. But the solution is to create new StoreKit Configuration file (in File -> New menu)

Adding StoreKit Configuration file

Then add all your products there. Use the same product id's as in AppStore Connect.

Adding products

Then add this file to Run Scheme configuration.

Setting Scheme Run options

Myxomatosis answered 23/9, 2019 at 15:29 Comment(7)
This also worked for me, on the release version of Xcode (and simulators). Before that point I encountered the same error in the iPad simulator, but not the iPhone simulator.Probative
Happens to me each time I start new simulator. Good job, Apple. :(Cordellcorder
I was going mad. (2) Restarting xCode and Simulator helps. Thanks a lot!Melquist
Thanks for your solution with the StoreKit Configuration file. We have added this to Xcode 12.2, as the Simulator always responded with ASDErrorDomain code 507, despite serval restarts of Xcode and Simulator. NOTE: When using this scheme on a real device, it will no longer retrieve the IAPs from the App Store, but read from the StoreKit Configuration file. So we have duplicated the scheme, and use the one with the StoreKit Configuration file on the Simulator only.Condemnatory
If you're unfamiliar with Xcode (like I am): schemes can be edited by navigating to Product > Scheme > Edit Scheme.Snippy
@Myxomatosis StoreKit Configuration is SO easy. It's how IAP should be handled!Climax
I have used StoreKit Configuration and it's working like a charm when I RUN the app on a simulator or device but when I deploy it to TestFlight then still getting an empty array of subscriptionsNitride
G
3

For those that has this issue in iOS 14.0, you still need to create the storekit configuration file as per @silvansky answer. Rather than adding it to the target, we can actully start an SKTestSession before making any product request in order to avoid the error.

if #available(iOS 14.0, *) {
    do {
        let session = try SKTestSession(configurationFileNamed: "Your_StoreKit_Configuration_File_Name")
        session.disableDialogs = true
    } catch {
        // catch error here
    }

    // Start your product request here
    let productIdentifiers = Set(["product_identifier_1", "product_identifier_2"])
    let productsRequest = SKProductsRequest(productIdentifiers: productIdentifiers)
    productsRequest.delegate = self

    // Run the request
    productsRequest.start()
}

You can refer to Apple's documentation for SKTestSession for more info: https://developer.apple.com/documentation/storekittest/sktestsession

Gargoyle answered 18/8, 2021 at 2:21 Comment(0)
G
1

I had the same issue, iOS13 Simulators produced the same error, iOS12 Simulators were working well. I then tried out on the iPhone with iOS13 installed, there the calls were working flawlessly too.

Hoping that it'll be fixed soon in Xcode Simulators, I guess until then we are stuck with the error.

Edit: Now it seems to work also in iOS 13 Simulator Devices.

Gladiatorial answered 23/9, 2019 at 13:33 Comment(1)
It's still happening in simulators after you reset all content and settings. Xcode 11.2.1 (11B500)Sheeran
T
1

Note: I've updated the answer, read the Edit part.

To share my experience, it seems that this problem does not exist any more in Xcode 11.1 GM Seed. There's no need to restart Simulators or Xcode to make in-app purchases work anymore.

I had submitted an app for review and it was rejected because of that particular error. As it turns out, it was rejected for a stupid reason as it wasn't my app's bug, however I spent hours trying to get around it.

So, just update to Xcode 11.1 GM Seed and run again. Everything will be okay.

EDIT

The issue still exists in Xcode 11.1 and apparently I was just lucky that it didn't happen to me again. However, I had a second rejection for the exact same reason. What eventually worked and made my app get approved was this:

I had to update my IAP record on App Store by editing and saving it again.

So, I recommend you to try the same; change something temporarily in your IAPs, save and then revert your changes (and save again) so records on the App Store to be refreshed.

FYI, after the second rejection Apple invalidated my IAP and therefore showed me the way. It looks like to be a known issue to them at the end.

For details read this discussion I wrote on Reddit.

Tommy answered 26/9, 2019 at 17:17 Comment(2)
@TimurBernikovich Thanks for the update, I've been told the same by others too. I edited my answer and I describe how it finally worked for me.Tommy
I'm still having this issue in Xcode 11.2.1 (11B500)Sheeran

© 2022 - 2024 — McMap. All rights reserved.