【发布时间】:2020-11-02 17:19:54
【问题描述】:
我正在尝试了解使用 Xcode 12 和 SwiftUI 实现 IAP。我使用 App Store Connect 准备了所有内容并注册了产品 ID。
我正在使用适应 SKProductsRequestDelegate 协议的 StoreManager 类来获取指定产品 id 的对应 SKProduct。
但是,即使我使用物理设备,func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) 也不会被调用。实际上,控制台什么也没打印。
我不明白为什么这个函数永远不会被调用。
class StoreManager: NSObject, SKProductsRequestDelegate {
override init() {
super.init()
getProducts()
}
func getProducts() {
let productID = "com.dev8882.MyDungeon.IAP.PowerSword"
let request = SKProductsRequest(productIdentifiers: Set([productID]))
request.delegate = self
request.start()
}
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
print("Did receive response")
}
}
【问题讨论】:
标签: swift xcode in-app-purchase