Skip to main content

Subscriptions

Before using any features that require an entitlement (such as VPN), the SDK needs to know which subscription to operate on. Call activateSubscription(for:) on the handle after authentication to select the correct subscription.

Activating a Subscription

Pass a predefined product type to select a subscription by its entitlement:

import KapeCore

// Activate using the built-in VPN product type
try handle.activateSubscription(for: .vpn)

The .vpn product type matches any subscription that carries the <tenant_id>.vpn entitlement (e.g. xv.vpn).

For custom or multi-product scenarios, pass explicit entitlement IDs:

// Activate using custom entitlement IDs
try handle.activateSubscription(for: .custom(values: ["acme.a", "acme.b"]))

A subscription is considered a match if it grants any of the provided entitlements.

info

If multiple subscriptions match, the SDK automatically selects the first one.

Typical Flow

activateSubscription(for:) is called once after a successful login, before initiating a VPN connection:

// 1. Authenticate
try await auth.login(presenting: viewController)

// 2. Activate the subscription
try handle.activateSubscription(for: .vpn)

// 3. Connect to VPN
try await vpn.connect(to: locationId)