Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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")
    }
}
like image 268
Stéphane de Luca Avatar asked Aug 23 '19 22:08

Stéphane de Luca


3 Answers

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.

like image 74
Stéphane de Luca Avatar answered Nov 20 '22 17:11

Stéphane de Luca


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.

like image 21
Alexander Ershov Avatar answered Nov 20 '22 18:11

Alexander Ershov


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

like image 2
pnizzle Avatar answered Nov 20 '22 17:11

pnizzle