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

configure()

Initialize the SDK with your public API key and optional UI configuration

identify()

Associate your user ID with Encore for cross-device tracking

setUserAttributes()

Set structured attributes for targeting and analytics

reset()

Clear user identification and cached entitlements on logout

Presenting Offers

placement()

Fluent API for presenting offers with optional callbacks or async/await

isActive()

Check if an entitlement is currently active for the user

isActivePublisher()

Reactive Combine publisher for entitlement state changes

Testing & Development

revokeEntitlements()

Admin method to revoke all entitlements for testing offer flows end-to-end

Types & Configuration

UserAttributes

Structured user attributes for targeting and personalization

Entitlements

Types of rewards granted when users accept offers

EncorePresentationResult

Possible outcomes when presenting an offer

NotGrantedReason

Reasons why an entitlement was not granted

Error Handling

Errors

Errors that can occur when using the SDK

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.