1

我正在尝试使用新的 StoreKit 2 API 测试我的 macOS 应用程序的 IAP。

我创建了一个.storekit文件,并在我的方案中分配了它运行 > 选项 > StoreKit 配置。

检索测试产品没有问题:

let identifiers = Set(["myProductId"])
let products = try await Product.products(for: identifiers)

但是当我想模拟购买时,什么也没有发生。它卡住了,从不打印结果。

func purchase(product: Product) async throws {
    print("Purchasing \(product.id) ...")
    let result = try await product.purchase()
    print(result)
}

我目前使用的是 macOS Monterey Beta 8 和 Xcode 13 beta 5。

4

1 回答 1

1

您必须确保沙盒配置为启用了传出连接(客户端):

沙盒配置

于 2021-10-10T16:32:16.977 回答