Skip to main content
This section documents the Encore iOS SDK’s complete public API in a consistent format with clean parameter tables, comprehensive usage examples, and best practices.
Looking for integration guides?
  • New to Encore? Start with the Getting Started Guide for portal-guided setup
  • Step-by-step integration: See the iOS Quickstart for detailed installation and configuration instructions
  • Advanced setups: This reference section is ideal for looking up specific methods, parameters, and advanced usage patterns

Core Methods

Presenting Offers

Testing & Development

Types & Configuration

Error Handling

Basic Integration

Passive Offer (No Callbacks)

// 1. Configure at launch
Encore.shared.configure(apiKey: "pk_your_api_key")

// 2. Identify user after login
Encore.shared.identify(userId: user.id)

// 3. Present offer (state managed automatically)
Encore.placement("cancellation_flow").show()

// 4. Check entitlements (async with automatic smart refresh)
Task {
  if await Encore.shared.isActive(.freeTrial(), in: .verified) {
    unlockPremiumFeatures()
  }
}

SwiftUI Pattern

struct CancellationView: View {
  var body: some View {
    Button("Cancel Subscription") {
      Encore.placement("cancellation_flow")
        .onGranted { entitlement in
          print("User accepted: \(entitlement)")
        }
        .onNotGranted { reason in
          proceedWithCancellation()
        }
        .show()
    }
  }
}

Async/Await Pattern

Button("Cancel Subscription") {
  Task {
    do {
      let result = try await Encore.placement("cancellation_flow").show()
      switch result {
      case .granted(let entitlement):
        print("User accepted: \(entitlement)")
      case .notGranted:
        proceedWithCancellation()
      }
    } catch {
      handleError(error)
    }
  }
}
The SDK automatically manages entitlement state through isActivePublisher. Callbacks are optional - use them only when you need custom flow control or analytics.