Repository navigation
Add a SwiftUI paywall example for every subscription state - #13
Merged
Merged
Conversation
Examples/PaywallDemo is a small iOS app that shows what the subscription status API is for: a paywall that does not pitch "Unlock Premium" to a customer whose card was just declined. - Grace period: access stays, and the screen asks for a payment-method update before the date access would end. - Billing retry: Premium is on hold rather than for sale. The plans are hidden and the main action opens the subscription settings, so nobody is sold a second subscription while they still have one. - Expired with auto-renew turned off gets the win-back offer. Expired after a billing error gets the promotional offer. Revoked means access is gone. Demo mode switches between live StoreKit and each of these states, using a stand-in built from the models' public initializers. A reader can see every state in a minute without Xcode's transaction manager, and the stand-in doubles as an example of mocking PurchasesProtocol. The same stand-in drives a SwiftUI preview for each state. The scheme's Run action uses PaywallDemo.storekit, so the app runs with no App Store Connect setup. The file defines monthly and yearly plans with a trial, a promotional and a win-back offer, a consumable and a lifetime unlock. The project uses the Xcode 26.3 format (objectVersion 100). It is the newest format the CI's Xcode 26.6 can open, and it matches the package's OS 26 floor. CI builds the example so it cannot fall behind the kit's API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Examples/PaywallDemois an iOS app showing a paywall that reacts to the five subscription states StoreKit 2reports: subscribed, grace period, billing retry, expired (with its reason) and revoked. It goes with the
article on subscription states. It also tours the public API:
subscriptionStatus(inGroup:),subscriptionStatusUpdates,PurchaseOptionswith win-back and promotional offers,catch PurchasesError.purchaseCancelled, andshowManageSubscriptions(in:).PurchasesProtocolstand-in builtfrom public initializers. The stand-in also drives a SwiftUI preview per state.
PaywallDemo.storekitvia the scheme, so no App Store Connect setup is needed.Grace period and billing retry can be reproduced through Debug → StoreKit → Manage Transactions.
objectVersion = 100). It is the newest format the CI's Xcode 26.6opens.
The package itself is unchanged:
Examples/is not part of any target, so no release is needed.Verified
xcodebuild build -project Examples/PaywallDemo/PaywallDemo.xcodeproj -scheme PaywallDemo -destination generic/platform=iOS\ Simulator CODE_SIGNING_ALLOWED=NOsucceeds with no warnings from the example's sources (Xcode 27.1).
swift buildandswift testof the package still pass (97 tests).StoreKit file. The app then shows an empty state that offers demo mode instead of a blank screen.