Skip to main content

Purpose

Create and present Encore offers using a fluent API that fits naturally in SwiftUI and UIKit. Purchases run through the EncorePurchaseController you register at configure() time.

Signature

placement(_:) returns a builder. Configure it with the optional builder methods, then call show():
Encore.placement(_:) is the one way to create a placement. The instance form Encore.shared.placement(_:) is deprecated and is removed in the next major release.

Methods

.presented means the interaction ran: the offer sheet, or on IAP-first variants the purchase sheet that stands in for it. headline(_:) and subheadline(_:) pass the full string through as-is; the SDK never composes copy out of a count. Priority is this override, then the copy Encore resolved for your app, then the shipped template default, and an empty string is ignored so it can’t blank the shipped copy. Encore never translates the string you pass, so localize it yourself. The copy Encore resolves for your app is translated into the user’s language. See Where the copy comes from and Localization.

Moment

In debug builds with logLevel: .debug, a placement shown with no moment logs one warning per placement. How to choose a moment type: Tell Encore the Moment.

Location and trigger

These describe the placement and belong to your app: they change when you ship a new screen or button, so pass them in code on each placement your own UI opens, after the moment. Both are optional. Use embedded when your launcher sits inside a screen, popup or sheet that shows other content (a button in a celebration popup), and standalone when the launcher is the whole UI that appears (a toast, a drop-down notice, a floating badge). Trigger components report their own trigger values. See Describe your placement in code.

Use cases

The raw values are the wire format the backend stores and that analytics splits the funnel on. The case names are the API surface; the raw values are the contract. .reduceChurn is the default surface for cancel flows and paywall declines. .rewardUsers presents the reward surface after the user has already done something worth celebrating (a completed purchase, a milestone, a streak); it is not a way to sell. It is claim-only: no in-app purchase runs anywhere in the path, and it never falls back to the paywall sheet. See Reward Users. If no enabled variant resolves for the requested use case, show() resolves with .notPresented(.useCaseUnavailable) and no UI appears.

Usage Patterns

The facade and builder are @MainActor, so call show() from a main-actor context: a SwiftUI button action, a .task, or a UIKit handler. A SwiftUI Button action is synchronous, so wrap the await in a Task:

Callback form

When the call site can’t await, show(resume:) delivers every outcome on the main actor:
There is no fire-and-forget show() in 2.x. Every presentation resolves exactly once, and the resolution is always delivered, so fallback logic can never be silently skipped.

Selecting a use case

show() is @MainActor: presentation always happens on the main thread. From nonisolated code, await hops to the main actor automatically and the result still resumes there.

Reward for trying

From 2.3.0, publisherReward(_:) describes a prize your app pays for trying an offer. When the user says they finished and Encore’s server grants the prize, result.claim?.userConfirmedCompletion is true on the result show() returns (or passes to show(resume:)), and your app grants the prize from that result only (the outcomes stream carries the same result, so granting from both pays twice). The server keys the prize on the ID you pass to identify(), so only identified users are promised one. Setup, the daily limit, and when the flag stays false: Reward for Trying.

Appearance

The sheet renders in light, dark, or automatic appearance, following the appearance mode configured for your app in the Encore dashboard. Automatic is the default: the presentation window is left unspecified, so the sheet inherits your app’s interface style and switches with it, with no work on your side. func appearance(_ config: AppearanceConfig) -> Self styles this presentation. Its sheet: SheetAppearance? field gives the reward sheet your fonts, colors, corners, and images per component; see Sheet Appearance.

SheetAppearance

AppearanceConfig.sheet styles a served reward sheet per component, and a value set in the Style editor (when it is on for your app) wins over app code per property. Fonts come from app code only. How to use it: Sheet Appearance.

Structure

Each struct also has a public init with one parameter per property. Optional properties default to nil (components to [:]), so SheetComponentStyle(fill: "#F9C23C") sets one property. A non-optional property, such as url and fallbackImage on SheetAnimation or from and duration on SheetEnter, has no default.

Field reference

SheetAppearance SheetComponentStyle: every field is optional. The element the variant draws decides which fields apply; a field that does not apply, or a value out of range, is dropped with a warning in the SDK log. animation enter and loop: both are skipped or held still when the device asks for reduced motion.