Stéphane de Luca
Stéphane de Luca

Reputation: 13573

IOS13 beta 5: Does SKProductsRequest supposed to work on simulator?

Though everything works great on actual devices, I wonder why the delegate is never called back on simulator on iOS 13 beta 5?

I searched the internet for an answer, but found nothing.

I implemented the 3 functions for the protocol as follows:

public class StoreKit {
    var request: SKProductsRequest? = nil   // Keep a strong reference

    public func fetchProducts() {
        print("\(#function): start fetching products")

        let r = SKProductsRequest(productIdentifiers: productIDs)
        request = r
        r.delegate = self
        r.start()
    }

}

// MARK: - Get the requested products

extension StoreKit: SKProductsRequestDelegate {
    /// Products are received
    public func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
        print("\(#function): did receive")
    }



    /// Unable to received the products
    public func request(_ request: SKRequest, didFailWithError error: Error) {
        print("\(#function): Error for request: \(error.localizedDescription)")

    }



    public func requestDidFinish(_ request: SKRequest) {
        print("\(#function): did finish")
    }
}

Upvotes: 7

Views: 2586

Answers (3)

pnizzle
pnizzle

Reputation: 6431

Xcode 11.2 (11B52) iOS 13.2 Simulator working for me

As mentioned in almost all suggestions to related issues- make sure you have fully completed setting up the product, eg an in-app purchase. Most importantly make sure your Agreements, Tax, and Banking section has been completed 100%:

  1. Go to App Store Connect
  2. Select Agreements, Tax, and Banking
  3. Under Agreement tab, make sure Free and Paid apps agreements show Active status
  4. Make sure you have filled all the required information on the remaining tabs.
  5. If in any of those tabs you are still seeing empty fields, or fields in which you can enter information, it means you are not done yet.

To quickly test your app's purchasable products you can use Apple's sample In app purchase example. You do need to give it your app's Bundle Id and list out the purchasable product id in a specific file. All instructions are there.

As of the date of this post, simulator SKProductsRequest is working perfectly.

enter image description here

Upvotes: 2

Stéphane de Luca
Stéphane de Luca

Reputation: 13573

The issue has been fixed by Apple in Xcode beta 6 (August 16th, 2019).

[UPDATE Sept 30th 2019]

For those who's still experience the issue, did you download Xcode v11.1 (11A1027), Released on September 24, 2019? I don't have any issue with it. If you still, try to add some information so that I can help you further.

Upvotes: 5

Alexander Ershov
Alexander Ershov

Reputation: 1157

Had the same problem, as mentioned in the comments to the author's answer.

( request:didFailWithError: with error message being: Error Domain=ASDErrorDomain Code=507 "Error decoding object" UserInfo={NSLocalizedDescription=Error decoding object, NSLocalizedFailureReason=Attempted to decode store response} )

I changed project's iOS deployment target to iOS 13.0 and products loaded successfully in a simulator.

Upvotes: 3

Related Questions