How can I use StoreKit 2 in SwiftUI
Generated on 2/21/2025
1 search
To use StoreKit 2 in SwiftUI, you can take advantage of several new features and APIs that make handling in-app purchases more efficient and user-friendly. Here are some key points from the WWDC session "What’s new in StoreKit and In-App Purchase":
-
Swift Async/Await Pattern: StoreKit 2 utilizes modern Swift language features like the async/await pattern. This allows you to perform tasks such as fetching product metadata, making purchases, and retrieving customer transaction history in a more streamlined and readable manner.
-
Subscription Picker API: You can create custom SwiftUI views to represent subscription options using the new subscription picker API. This involves creating a view for each subscription option and a button to trigger the purchase.
-
Custom Control Styles: StoreKit 2 allows you to implement custom control styles for your subscription store view. This gives you creative control over how your in-app purchases are merchandised while leveraging StoreKit's infrastructure.
-
Testing in Xcode: The session also highlights the importance of testing your in-app purchase flows using Xcode's transaction manager, which is essential for debugging and ensuring a smooth user experience.
For more detailed information, you can refer to the session What’s new in StoreKit and In-App Purchase (21:06) where these updates are discussed.

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.

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.