All skills

Use when implementing in-app purchases, StoreKit 2 subscriptions, consumables, non-consumables, or transaction handling. Covers testing-first workflow with .storekit configuration, StoreManager architecture, and transaction verification.

Use this Skill: https://skilld.dev/gh/johnrogers/claude-swift-engineering/storekit

This session only. Nothing lands on disk.

referencessubscriptions.md

≈769 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Subscriptions

Auto-renewable subscription management with StoreKit 2.

Subscription Properties

if let info = product.subscription {
    let groupID = info.subscriptionGroupID
    let period = info.subscriptionPeriod  // .day, .week, .month, .year
}

Subscription Status

let statuses = try await Product.SubscriptionInfo.status(for: groupID)

for status in statuses {
    switch status.state {
    case .subscribed:        // Active - full access
    case .expired:           // Show resubscribe/win-back
    case .inGracePeriod:     // Billing issue, access maintained
    case .inBillingRetryPeriod:  // Apple retrying payment
    case .revoked:           // Family Sharing removed
    @unknown default: break
    }
}

Listen for Status Updates

for await statuses in Product.SubscriptionInfo.Status.updates(for: groupID) {
    for status in statuses { updateUI(for: status.state) }
}

Renewal Info

switch status.renewalInfo {
case .verified(let renewalInfo):
    renewalInfo.willAutoRenew       // Will subscription renew?
    renewalInfo.autoRenewPreference // Product ID for next renewal
    renewalInfo.expirationReason    // Why expired?
case .unverified: break
}

Expiration Reasons

Reason Action
.autoRenewDisabled User turned off renewal
.billingError Payment issue
.didNotConsentToPriceIncrease Show win-back offer
.productUnavailable Product discontinued

Grace Period

if let expiration = renewalInfo.gracePeriodExpirationDate {
    // Show update payment method UI
}

Offers

Introductory Offer

if let intro = product.subscription?.introductoryOffer {
    intro.period       // Duration
    intro.displayPrice // Price
    intro.paymentMode  // .freeTrial, .payAsYouGo, .payUpFront
}

Promotional Offers

for offer in product.subscription?.promotionalOffers ?? [] {
    offer.id, offer.displayPrice, offer.period
}

// Apply with server-signed JWS
let result = try await product.purchase(
    confirmIn: scene,
    options: [.promotionalOffer(offerID: offer.id, signature: jwsSignature)]
)

Subscription Groups

Users have one active subscription per group. Use for tier levels (Basic/Pro/Premium) or billing periods (Monthly/Annual).

let activeStatus = statuses.filter { $0.state == .subscribed }.first

Family Sharing

Family Sharing transactions have appAccountToken == nil. Each family member has unique appTransactionID.

Enable: App Store Connect > Subscriptions > Enable Family Sharing

Tracking Status

extension StoreManager {
    var isSubscribed: Bool {
        get async {
            let state = try? await Product.SubscriptionInfo.status(for: "pro_tier").first?.state
            return state == .subscribed || state == .inGracePeriod || state == .inBillingRetryPeriod
        }
    }
}

Win-Back Offers

if renewalInfo.expirationReason == .didNotConsentToPriceIncrease {
    showWinBackOffer()
}

Source: SKILL.md on GitHub

1 warning16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The storekit skill provides technical documentation and architectural patterns for implementing Apple's StoreKit 2 in-app purchase framework. It emphasizes security best practices such as transaction verification and main-thread safety, and contains no malicious content or suspicious patterns.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    6/6 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at d62eb71. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 9 months ago

README badge

README badge for johnrogers/claude-swift-engineering/storekit