how to use storekit 2

Generated on 8/12/2024

1 search

To use StoreKit 2, you can take advantage of several new features and improvements over the original StoreKit API. StoreKit 2 utilizes modern Swift language features, such as the Swift Async/Await pattern, to perform tasks like fetching product metadata, purchasing, and retrieving customer transaction history. This makes handling in-app purchases more efficient and straightforward.

Here are some key points about using StoreKit 2:

  1. Async/Await Pattern: StoreKit 2 uses the Swift Async/Await pattern, which simplifies asynchronous code, making it easier to read and maintain.

  2. Back Deployment: Thanks to the back-deployed attribute in Swift, StoreKit 2 allows you to access new App Store features even on devices with older operating systems.

  3. Testing Enhancements: StoreKit 2 provides enhanced testing capabilities in Xcode, allowing you to test your in-app purchase flows more effectively. You can set up a StoreKit configuration file with your product metadata to test your app's behavior locally.

  4. Custom UI: Starting in iOS 18, you can create custom control styles for your subscription store, using the same primitives that StoreKit uses for standard styles.

  5. Deprecation of Original API: The original API for in-app purchases is deprecated starting with iOS 18. It's recommended to update your app to use StoreKit 2 to ensure you have access to the latest features and improvements.

For more detailed information, you can refer to the session What’s new in StoreKit and In-App Purchase (21:06) from WWDC 2024, which covers updates to StoreKit 2.