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")
}
}
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.
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.
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%:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With