Xcode 14 中的沙箱环境让我感到困惑。
我正在尝试测试以下场景:
应用程序被删除后,它会清除“调试”>“Storekit”中的所有沙盒交易数据。
那么,当我重新编译应用程序时没有可检索的数据时,如何测试这种情况?
每次用户启动您的应用程序时,您都可以使用 Transaction 的
currentEntitlements
属性来恢复他们的购买,如以下 apple 文档中的代码所示
func refreshPurchasedProducts() async {
// Iterate through the user's purchased products.
for await verificationResult in Transaction.currentEntitlements {
switch verificationResult {
case .verified(let transaction):
// Check the type of product for the transaction
// and provide access to the content as appropriate.
...
case .unverified(let unverifiedTransaction, let verificationError):
// Handle unverified transactions based on your
// business model.
...
}
}
}