Revenuecat

From moasq/nanowave · View interactive version

Revenuecat is an AI agent skill from the GitHub repository moasq/nanowave. RevenueCat SDK patterns for in-app purchases, subscriptions, and entitlements. Use when implementing monetization features with RevenueCat.

How to use this skill

Skill file

RevenueCat Integration

SDK Initialization

Configure RevenueCat in your App's init() with StoreKit 2:

import RevenueCat

@main
struct MyApp: App {
    init() {
        #if DEBUG
        Purchases.logLevel = .debug
        #endif
        Purchases.configure(
            with: Configuration.Builder(withAPIKey: AppConfig.revenueCatAPIKey)
                .with(storeKitVersion: .storeKit2)
                .build()
        )
    }
}

The API key comes from AppConfig.revenueCatAPIKey — NEVER hardcode it inline.

Fetching Offerings

let offerings = try await Purchases.shared.offerings()
if let current = offerings.current {
    for package in current.availablePackages {
        let product = package.storeProduct
        let price = product.localizedPriceString  // "$9.99" — dynamic from store
        let name = product.localizedTitle          // "Premium Monthly"
    }
}

Purchasing

let result = try await Purchases.shared.purchase(package: package)
if !result.userCancelled {
    let isPremium = result.customerInfo.entitlements[AppConfig.entitlementID]?.isActive == true
}

Handle errors:

Checking Entitlements

ALWAYS use AppConfig.entitlementID — never hardcode the entitlement string:

let customerInfo = try await Purchases.shared.customerInfo()
let isPremium = customerInfo.entitlements[AppConfig.entitlementID]?.isActive == true

Reactive Updates

for try await customerInfo in Purchases.shared.customerInfoStream {
    let isPremium = customerInfo.entitlements[AppConfig.entitlementID]?.isActive == true
}

Restore Purchases

let customerInfo = try await Purchases.shared.restorePurchases()

User Account Linking

When using authentication (Supabase, Firebase, etc.), link the user ID:

let (customerInfo, _) = try await Purchases.shared.logIn(userId)

Call logIn after the user authenticates. Call logOut on sign-out:

let customerInfo = try await Purchases.shared.logOut()

CRITICAL: No Hardcoded Values

See SDK Setup, Purchase Flow, and Entitlements for detailed patterns.

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.