Mac Catalyst上的应用程序内购买不起作用 [英] In App Purchase on Mac Catalyst Not Working

查看:179
本文介绍了Mac Catalyst上的应用程序内购买不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用内购买对于我的iOS设备来说效果很好.来自StoreKit的数据将按应有的方式进行填充.相同的代码不适用于该项目的Mac Catalyst版本.我什至在App Store上为Mac应用程序创建了清单,并为应用程序内购买使用了不同的捆绑包标识符.我有一个打印功能,可以返回StoreKit找到的产品,它在iOS上运行良好,但是在使用Mac Catalyst时却没有任何结果.

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.

这是我所做的:

  1. 确保已在功能"部分添加了应用内购买".
  2. 确保已导入Store Kit框架.
  3. 确保分发包标识符正确.
  4. 确保已填写所有协议.
  5. 我已退出Mac App Store.

在iOS上有效但在MacOS上无效的代码:

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)")}

iOS应用将返回产品标识符,标题和价格. Mac应用程序将一无所获地返回.

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

推荐答案

我发现了问题.我没有为我的产品请求创建强大的参考.

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!

这篇关于Mac Catalyst上的应用程序内购买不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆