2024 App ServicesSwiftUI & UI FrameworksApp Store, Distribution & Marketing
WWDC24 · 23 min · App Services / SwiftUI & UI Frameworks / App Store, Distribution & Marketing
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.
Watch at developer.apple.com ↗Chapters
Code shown on screen · 4 snippets
Destination Video Shop
import StoreKit
import SwiftUI
struct DestinationVideoShop: View {
var body: some View {
SubscriptionStoreView(groupID: Self.subscriptionGroupID) {
SubscriptionOptionGroupSet { product in
StreamingPassLevel(product)
} label: { streamingPassLevel in
Text(streamingPassLevel.localizedTitle)
} marketingContent: { streamingPassLevel in
StreamingPassMarketingContent(level: streamingPassLevel)
StreamingPassFeatures(level: streamingPassLevel)
}
}
.subscriptionStoreControlStyle(.compactPicker, placement: .bottomBar)
}
} Subscription Option Groups - Tabs style
SubscriptionStoreView(groupID: Self.subscriptionGroupID) {
SubscriptionOptionGroupSet { product in
StreamingPassLevel(product)
} label: { streamingPassLevel in
Text(streamingPassLevel.localizedTitle)
} marketingContent: { _ in
StreamingPassMarketingContent()
}
}
.subscriptionStoreControlStyle(.compactPicker, placement: .bottomBar)
.subscriptionStoreOptionGroupStyle(.tabs) Subscription Option Groups - Links style
SubscriptionStoreView(groupID: Self.subscriptionGroupID) {
SubscriptionOptionGroupSet { product in
StreamingPassLevel(product)
} label: { streamingPassLevel in
Text(streamingPassLevel.localizedTitle)
} marketingContent: { _ in
StreamingPassMarketingContent()
}
}
.subscriptionStoreControlStyle(.compactPicker, placement: .bottomBar)
.subscriptionStoreOptionGroupStyle(.links) Custom control style implementation
import StoreKit
import SwiftUI
struct BadgedPickerControlStyle: SubscriptionStoreControlStyle {
func makeBody(configuration: Configuration) -> some View {
SubscriptionPicker(configuration) { pickerOption in
HStack(alignment: .top) {
VStack(alignment: .leading) {
Text(pickerOption.displayName)
.font(title2.bold())
Text(priceDisplay(for: pickerOption))
if pickerOption.isFamilyShareable {
FamilyShareableBadge()
}
Text(pickerOption.description)
}
Spacer()
SelectionIndicator(pickerOption.isSelected)
}
} confirmation: { option in
SubscribeButton(option)
}
}
}
struct DestinationVideoShop: View {
var body: some View {
SubscriptionStoreView(groupID: Self.subscriptionGroupID) {
SubscriptionPeriodGroupSet { _ in
StreamingPassMarketingContent()
}
}
.subscriptionStoreControlStyle(BadgedPickerControlStyle())
}
} Resources
- Testing in-app purchases with StoreKit transaction manager in Xcode
- Product.SubscriptionInfo.RenewalInfo
- Transaction properties
- Forum: App Store Distribution & Marketing
- Message
- StoreKit views
- Introducing StoreKit 2
- Setting up StoreKit Testing in Xcode
- In-App Purchase
- Original API for In-App Purchase
Related sessions
-
25 min -
38 min -
35 min -
37 min -
24 min -
33 min