内购如何迁移到StoreKit2
Generated on 2/10/2025
1 search
To migrate your in-app purchases to StoreKit 2, you should consider the following steps as highlighted in the session "What’s new in StoreKit and In-App Purchase" from WWDC 2024:
-
Deprecation of Original API: The original API for in-app purchases is deprecated starting with iOS 18. While existing apps will continue to function, the legacy API will not receive new features or enhancements. Therefore, it's recommended to update your app to use StoreKit 2.
-
Benefits of StoreKit 2: StoreKit 2 offers several improvements, such as:
- Access to customer transaction history and subscription renewal information.
- Automatic cryptographic validation.
- Utilization of modern language features like Swift's Async/Await pattern for tasks such as fetching product metadata and purchasing.
- Backward compatibility with older operating systems through the back-deployed attribute in Swift.
-
Testing and Implementation: StoreKit 2 provides a suite of tools to simplify handling in-app purchases. You can test your in-app purchase flows using StoreKit testing in Xcode, which allows you to simulate purchase intents and billing issues directly in your app.
For more detailed guidance, you can refer to the Update to StoreKit 2 (21:06) section of the session.

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.

Implement App Store Offers
Learn how to engage customers with App Store Offers using App Store Connect, as well as the latest StoreKit features and APIs. Discover how you can set up win-back offers (a new way to re-engage previous subscribers) and generate offer codes for Mac apps. And find out how to test offers in sandbox and Xcode to make sure they work smoothly.