Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

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 ↗

Transcript all transcripts

Chapters

Code shown on screen · 4 snippets

Destination Video Shop swift · at 4:26 ↗
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 swift · at 9:06 ↗
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 swift · at 9:20 ↗
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 swift · at 13:41 ↗
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