What is the best way to implement StoreKit 2 with a StoreView for my subscription based app?
Generated on 9/6/2024
1 search
To implement StoreKit 2 with a StoreView for your subscription-based app, you can follow these steps based on the information from the WWDC sessions:
-
Set Up StoreKit Configuration: Begin by setting up a StoreKit configuration file with your product metadata. This is essential for getting the in-app purchase UI working with Xcode previews. For more detailed guidance, you can refer to previous WWDC sessions like "What's New in StoreKit Testing" from WWDC 22 and "Introducing StoreKit Testing in Xcode" from WWDC 20.
-
Declare a Subscription Store View: Create a view for your subscription store. You can start by declaring a subscription store view and providing the group ID for your subscription. This is a straightforward process that allows you to structure your store to display different subscription levels.
-
Use Swift Async/Await: Utilize the Swift Async/Await pattern to perform tasks such as fetching product metadata, purchasing, and retrieving customer transaction history. This modern approach simplifies handling in-app purchases.
-
Customize Subscription Store Views: You can customize the appearance of your subscription store. Starting in iOS 18, you can create custom control styles to match your app's design. This involves declaring a type that conforms to the subscription store control style protocol and using the new subscription picker API.
-
Implement Preferred Subscription Offers: Use the Preferred Subscription Offer API to control which offer to display when multiple offers are available. This API allows you to fetch offer metadata and set up purchases, providing flexibility in how you present subscription options to users.
-
Test in Xcode: Leverage StoreKit testing in Xcode to ensure your in-app purchase flows work as expected. This includes testing privacy policies and license agreements locally, which can be done with the new settings in Xcode 16.
For more detailed information, you can refer to the session What’s new in StoreKit and In-App Purchase (15:35) for testing in Xcode and Implement App Store Offers (19:55) for using the Preferred Subscription Offer API.
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.