In App Purchase on Mac Catalyst Not Working

霸气de小男生 提交于 2020-07-22 03:57:50

问题


In app purchases work fine for my iOS side of things. The data from StoreKit is populated as it should. The same code doesn't work on the Mac Catalyst version of the project. I have even created a listing for my Mac app on App Store connect with different bundle identifiers for the in app purchases. I have a print function that returns what product StoreKit found, it works well on iOS, but results with nothing when using Mac Catalyst.

Here is what I have done:

  1. Make sure that In App purchases has been added in the capabilities section.
  2. Make sure the Store Kit framework has been imported.
  3. Make sure the bundle identifiers are correct.
  4. Make sure all agreements are filled out.
  5. I am signed out of the Mac App Store.

Code that works on iOS but not on MacOS:

    override func viewDidLoad() {
    SKPaymentQueue.default().add(self)


    let productIds: Set<String> = ["..."]
    var request = SKProductsRequest(productIdentifiers: productIds)
    request.delegate = self
    request.start()
}

  func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
    print("Loaded")

    for product in response.products {
        print("What came: \(product.productIdentifier) \(product.localizedTitle) \(product.price.floatValue)")}

The iOS app will return with the Product Identifier, Title and Price. The Mac app will return with nothing at all.


回答1:


I found the problem. I had not created a strong reference to my product request.

This line of code fixed my issue:

var request: SKProductsRequest!


来源:https://stackoverflow.com/questions/61802978/in-app-purchase-on-mac-catalyst-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!