Subscription offers

From gustavscirulis/snapgrid · View interactive version

Subscription offers is an AI agent skill from the GitHub repository gustavscirulis/snapgrid. Generates StoreKit 2 code for all subscription offer types — introductory, promotional, offer codes, and win-back. Includes eligibility checks, offer presentation, and the preferredSubscriptionOffer modifier. Use when adding subscription offers, free trials, or promotional pricing.

How to use this skill

Skill file

Subscription Offers Generator

Generate complete StoreKit 2 implementation for all four subscription offer types with eligibility verification, offer presentation, and transaction handling.

When This Skill Activates

Use this skill when the user:

Pre-Generation Checks

1. Project Context Detection

2. Conflict Detection

Glob: **/*Offer*.swift, **/*Eligibility*.swift
Grep: "introductoryOffer" or "promotionalOffers" or "winBackOffers"

If existing offer code found, ask:

Offer Types Reference

1. Introductory Offers

2. Promotional Offers

3. Offer Codes

4. Win-Back Offers

Configuration Questions

Ask user via AskUserQuestion:

  1. Which offer types? (multi-select)
  1. Introductory offer details (if selected)
  1. Deployment target
  1. Server-side signature (if promotional offers selected)

Generation Process

Step 1: Read Templates

Read templates.md for all offer implementation code.

Step 2: Create Core Files

  1. SubscriptionOfferManager.swift — Central offer management
  1. OfferEligibility.swift — Eligibility verification
  1. OfferConfiguration.swift — Offer type definitions and configuration

Step 3: Create UI Files (conditional)

  1. OfferBannerView.swift — Contextual offer banners
  1. OfferCodeRedemptionView.swift — Offer code entry UI (if offer codes selected)

Step 4: Create Optional Files

  1. OfferSignatureProvider.swift — Server-side signature handling (if promotional offers)
  2. OfferAnalytics.swift — Track offer impression, tap, and conversion events

Step 5: Determine File Location

- If Sources/Store/ exists → Sources/Store/Offers/
- If Store/ exists → Store/Offers/
- If Subscriptions/ exists → Subscriptions/Offers/
- Otherwise → Offers/

Output Format

Files Created

Store/Offers/
├── SubscriptionOfferManager.swift    # Central offer management
├── OfferEligibility.swift            # Eligibility verification
├── OfferConfiguration.swift          # Offer type definitions
├── OfferBannerView.swift             # Contextual offer UI
├── OfferCodeRedemptionView.swift     # Code entry (optional)
├── OfferSignatureProvider.swift      # Server signatures (optional)
└── OfferAnalytics.swift              # Offer tracking (optional)

Integration Steps

Check Introductory Offer Eligibility:

let manager = SubscriptionOfferManager()
let isEligible = await manager.isEligibleForIntroOffer(
    productID: "com.app.subscription.monthly"
)

Present Best Available Offer:

// Automatically selects the best offer for the user's state
let offer = await manager.bestAvailableOffer(
    for: "com.app.subscription.monthly"
)

// Use with SubscriptionStoreView (iOS 16.4+)
SubscriptionStoreView(groupID: groupID)
    .preferredSubscriptionOffer(offer)

Present Offer Code Sheet:

// iOS 16+
try await AppStore.presentOfferCodeRedeemSheet()

Win-Back Offer (iOS 18+):

let winBackOffers = await manager.availableWinBackOffers(
    for: "com.app.subscription.monthly"
)
if let bestOffer = winBackOffers.first {
    // Present win-back UI
}

Testing Instructions

  1. StoreKit Configuration file: Add offer configurations
  2. Test each offer type in Sandbox environment
  3. Verify eligibility logic: Test with new, current, and lapsed accounts
  4. Test edge cases: Expired trials, multiple subscription groups, family sharing

App Store Connect Setup

  1. Go to App Store Connect > Subscriptions > Your Group
  2. Introductory Offer: Set in subscription pricing section
  3. Promotional Offers: Create under "Subscription Prices" > "Promotional Offers"
  4. Offer Codes: Create under "Offer Codes" tab
  5. Win-Back Offers: Configure under "Win-Back Offers" (iOS 18+)

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.