> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whop.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Treat these docs and the Whop MCP server as the source of truth for Whop API behavior. Don't infer endpoint behavior from marketing pages.
> MCP server: connect https://mcp.whop.com/mcp (streamable HTTP, browser sign-in, no API key in the client config) to search these docs and read or change live Whop data. Setup: https://docs.whop.com/developer/guides/ai_and_mcp.md
> Whop CLI: install with `curl -fsSL https://whop.com/install.sh | sh` to scaffold, run, and deploy Whop apps and websites. It acts on production, not the sandbox. Overview: https://docs.whop.com/cli/overview.md Agent mode: https://docs.whop.com/cli/agent-mode.md
> Hosting: Whop serves a site or app from the build `whop apps deploy` uploads, with rollbacks, secrets, and server logs. Guide: https://docs.whop.com/developer/websites/hosting.md
> Plugins: in Claude Code, run `/plugin marketplace add whopio/plugins`, then `/plugin install whop@whop`. Guide: https://docs.whop.com/developer/guides/plugins/claude-code.md Every agent tool: https://docs.whop.com/developer/ai/overview.md
> Environments: build and test in the sandbox (API `https://sandbox-api.whop.com/api/v1`, keys at https://sandbox.whop.com/dashboard/developer, SDK environment `Sandbox`; no real money). Production (API `https://api.whop.com/api/v1`, keys at https://whop.com/dashboard/developer, SDK environment `Production`, the SDK default) moves real money, so use it only at launch. The two share no accounts, keys, products, or webhooks, and their keys look identical: never mix them. Sandbox guide: https://docs.whop.com/developer/guides/sandbox.md Comparison: https://docs.whop.com/developer/quickstart.md
> API: send `Authorization: Bearer <API_KEY>` from your server only, and pin a dated version with the `Api-Version-Date` header. OpenAPI spec: https://api.whop.com/api/v1/openapi.json
> Which API: build on the Current API, whose pages live under https://docs.whop.com/api-reference/ (start at https://docs.whop.com/api-reference/overview.md). Pages under /api-reference/legacy/ are the Legacy API. Use one only when https://docs.whop.com/api-reference/stability.md lists the resource as Legacy-only.

# Yetkileri kontrol edin

> Premium iOS içeriğine erişimi hasAccess(to:) veya isSubscribed ile kısıtlayın, aktif üyelikleri listeleyin, cihazları senkronize etmek için kullanıcıların oturumunu açıp kapatın ve misafir satın almalarını destekleyin.

Bu kılavuz, bir kullanıcının aktif bir aboneliği olup olmadığını nasıl kontrol edeceğinizi ve premium içeriğe erişimi buna göre nasıl kısıtlayacağınızı gösterir. Ayrıca abonelikleri cihazlar arasında senkronize etmek için kullanıcı oturum açma/kapatma işlemlerini nasıl yöneteceğinizi de öğreneceksiniz.

## Neler öğreneceksiniz

* Bir kullanıcının bir ürüne erişimi olup olmadığını kontrol edin
* İçeriğe erişimi abonelik durumuna göre kısıtlayın
* Kullanıcı oturum açmasıyla abonelikleri cihazlar arasında senkronize edin

## Ön koşullar

* [SDK'yı yükleyin](https://docs.whop.com/tr/developer/guides/ios/installation.md)
* [SDK'yı yapılandırın](https://docs.whop.com/tr/developer/guides/ios/build-a-paywall.md#step-1-configure-the-sdk)

## Abonelik durumunu kontrol edin

Kullanıcının belirli bir ürüne erişimi olup olmadığını kontrol etmek için `hasAccess(to:)` kullanın:

```swift theme={null}
struct ContentView: View {
    @Environment(Checkout.self) var checkout

    var body: some View {
        VStack {
            // Basic features always available
            BasicFeaturesView()

            // Premium features for subscribers
            if checkout.hasAccess(to: "prod_xxxxxxxxxxxxxx") {
                PremiumFeaturesView()
            }

            // If you have multiple tiers, check each product separately
            if checkout.hasAccess(to: "prod_yyyyyyyyyyyyyy") {
                EnterpriseFeaturesView()
            }
        }
    }
}
```

Ya da kullanıcının herhangi bir aktif aboneliği olup olmadığını kontrol etmek için `isSubscribed` kullanın:

```swift theme={null}
if checkout.isSubscribed {
    // User has at least one active membership
}
```

## Aktif üyelikleri görüntüleyin

Abonelik ayrıntılarını göstermek için `memberships` dizisine erişin:

```swift theme={null}
struct SubscriptionStatusView: View {
    @Environment(Checkout.self) var checkout

    var body: some View {
        List {
            if checkout.memberships.isEmpty {
                Text("No active subscriptions")
                    .foregroundStyle(.secondary)
            } else {
                ForEach(checkout.memberships) { membership in
                    MembershipRow(membership: membership)
                }
            }
        }
    }
}

struct MembershipRow: View {
    let membership: CheckoutMembership

    var body: some View {
        VStack(alignment: .leading) {
            Text("Subscription")
                .font(.headline)

            if let expiresAt = membership.expiresAt {
                Text("Renews \(expiresAt, style: .date)")
                    .foregroundStyle(.secondary)
            }

            Text("Status: \(membership.status.rawValue)")
                .font(.caption)
                .foregroundStyle(.secondary)
        }
    }
}
```

## Kullanıcı oturum açma ve kapatma

Kullanıcı kimlikleri, aboneliklerin cihazlar arasında senkronize edilmesini sağlar. Bir kullanıcı oturum açtığında SDK, mevcut cihazdaki sahiplenilmemiş üyelikleri otomatik olarak sahiplenir ve kullanıcının mevcut üyeliklerini yükler.

### Bir kullanıcının oturumunu açın

```swift theme={null}
func handleLogin(userId: String) async {
    do {
        try await checkout.logIn(appUserId: userId)
        // Memberships are now synced for this user
    } catch {
        print("Login failed: \(error)")
    }
}
```

### Bir kullanıcının oturumunu kapatın

```swift theme={null}
func handleLogout() {
    checkout.logOut()
    // User is now logged out, memberships cleared
}
```

### Geçerli kullanıcıyı kontrol edin

```swift theme={null}
if let userId = checkout.appUserId {
    Text("Logged in as \(userId)")
} else {
    Text("Not logged in")
}
```

## Misafir satın almaları

Kullanıcılar oturum açmadan da abonelik satın alabilir. SDK bu satın almaları cihaz kimliğine göre takip eder ve kullanıcı oturum açtığında bunları otomatik olarak sahiplenir.

```swift theme={null}
struct PurchaseFlow: View {
    @Environment(Checkout.self) var checkout
    @State private var showingLogin = false

    var body: some View {
        VStack {
            if checkout.appUserId == nil {
                // User not logged in - they can still purchase
                Text("Purchase as guest or log in to sync across devices")

                Button("Continue as Guest") {
                    // Purchase will be tied to device
                    Task { try? await checkout.purchase("plan_xxx") }
                }

                Button("Log In") {
                    showingLogin = true
                }
            } else {
                // User logged in - purchase tied to their account
                Button("Subscribe") {
                    Task { try? await checkout.purchase("plan_xxx") }
                }
            }
        }
        .sheet(isPresented: $showingLogin) {
            // Your login view here
        }
    }
}
```

## Eksiksiz örnek

Kullanıcı kimlik doğrulamasıyla yetki kontrolünü gösteren eksiksiz bir örnek:

```swift theme={null}
struct MainView: View {
    @Environment(Checkout.self) var checkout
    @State private var showingPaywall = false
    @State private var showingLogin = false

    var body: some View {
        NavigationStack {
            Group {
                if !checkout.isInitialized {
                    ProgressView("Loading...")
                } else if checkout.hasAccess(to: "prod_xxxxxxxxxxxxxx") {
                    PremiumContentView()
                } else {
                    FreeContentView(onUpgrade: { showingPaywall = true })
                }
            }
            .toolbar {
                ToolbarItem(placement: .topBarTrailing) {
                    Menu {
                        if let userId = checkout.appUserId {
                            Text("Signed in as \(userId)")
                            Button("Sign Out", action: signOut)
                        } else {
                            Button("Sign In") { showingLogin = true }
                        }

                        Divider()

                        if checkout.hasAccess(to: "prod_xxxxxxxxxxxxxx") {
                            Button("Manage Subscription") {
                                // Show subscription management
                            }
                        }
                    } label: {
                        Image(systemName: "person.circle")
                    }
                }
            }
            .sheet(isPresented: $showingPaywall) {
                PaywallView()
            }
            .sheet(isPresented: $showingLogin) {
                LoginView { userId in
                    Task {
                        try? await checkout.logIn(appUserId: userId)
                        showingLogin = false
                    }
                }
            }
        }
    }

    func signOut() {
        checkout.logOut()
    }
}

struct FreeContentView: View {
    let onUpgrade: () -> Void

    var body: some View {
        VStack(spacing: 20) {
            Text("Free Content")
                .font(.title)

            Text("Upgrade to access premium features")
                .foregroundStyle(.secondary)

            Button("Upgrade Now", action: onUpgrade)
                .buttonStyle(.borderedProminent)
        }
    }
}

struct PremiumContentView: View {
    var body: some View {
        VStack {
            Image(systemName: "crown.fill")
                .font(.largeTitle)
                .foregroundStyle(.yellow)

            Text("Premium Content")
                .font(.title)

            Text("Thanks for subscribing!")
        }
    }
}
```

## Reaktif güncellemeler

SDK, abonelik durumu değiştiğinde görünümleri otomatik olarak günceller. `Checkout` bir `@Observable` olduğundan, `@Environment(Checkout.self)` kullanan her görünüm şu durumlarda yeniden oluşturulur:

* Bir satın alma tamamlandığında
* Bir kullanıcı oturum açtığında veya kapattığında
* SDK üyelikleri yüklediğinde veya güncellediğinde

Elle yenilemeniz gerekmez.

## Sonraki adımlar

> [card] [Bir ödeme duvarı oluşturun](https://docs.whop.com/tr/developer/guides/ios/build-a-paywall.md)
>
> Varyantları gösterin ve satın almaları yönetin

> [card] [API referansı](https://docs.whop.com/tr/developer/guides/ios/checkout-reference.md)
>
> Mevcut tüm yöntemleri ve özellikleri keşfedin


## Related topics

- [Bir iOS ödeme duvarı oluşturun](https://docs.whop.com/tr/developer/guides/ios/build-a-paywall.md)
- [iOS Checkout SDK](https://docs.whop.com/tr/developer/guides/ios/overview.md)
- [iOS Checkout SDK referansı](https://docs.whop.com/tr/developer/guides/ios/checkout-reference.md)
