sk2 下,如何 finish transaction
Asked on 2025-07-28
1 search
在 StoreKit 2 中,处理交易的完成状态变得更加简化。根据 WWDC 2024 的 "What’s new in StoreKit and In-App Purchase" 会议中提到的内容,您可以通过以下步骤来完成交易:
-
启用已完成的消耗品交易历史:在 iOS 18 中,交易历史 API 包括已完成的消耗品交易。要开始接收已完成消耗品的交易,您需要在项目的 info plist 文件中设置
SKIncludeConsumableInAppPurchaseHistory
键为true
。 -
监听交易:一旦启用,您可以像往常一样监听交易。框架将提供所有消耗品的交易,无论其完成状态如何。
-
自动验证:StoreKit 2 自动处理交易的验证,因此您不需要手动验证交易。
要了解更多关于 StoreKit 2 的信息,您可以查看 What’s new in StoreKit and In-App Purchase (00:00:51) 会议的详细内容。

What’s new in StoreKit and In-App Purchase
Learn how to build and deliver even better purchase experiences using the App Store In-App Purchase system. We’ll demo new StoreKit views control styles and new APIs to improve your subscription customization, discuss new fields for transaction-level information, and explore new testability in Xcode. We’ll also review an important StoreKit deprecation.

What’s new in StoreKit and In-App Purchase
Learn about the latest StoreKit API enhancements to help you deliver great In-App Purchase experiences to your customers. We’ll review new fields added to AppTransaction, Transaction, and RenewalInfo, and updates to In-App Purchase offer codes. We’ll also cover creating signed In-App Purchase requests using the App Store Server Library and updates to merchandising subscriptions using SwiftUI.

Finish tasks in the background
Discover background execution advancements and understand how the system schedules runtime. We’ll discuss how to get the most out of background runtime to allow your app to deliver features in the background while maintaining a great foreground experience. We’ll also cover how APIs provide background runtime for your app, and how each API is tailored for different use cases — including new APIs in iOS and iPadOS 26 that let your app finish tasks as your app transitions from the foreground to the background.