Overview
await Encore.shared.placement(_:).show() returns a PresentationResult: the factual record of the presentation. It never throws, and it resolves exactly once. Three rules cover almost every integration:
- Invoke
show()from a main-actor context. The facade and builder are@MainActor. - Results are values: await inline for control flow. Branch on the result where the context lives.
outcomesis for passive observers. Analytics, debug overlays, and cross-screen state consume the stream instead of owning a call site.
Rule 1: Invoke show() from a main-actor context
Callshow() from a SwiftUI button action, a .task, or a UIKit handler; you are already on the main actor there, and the compiler enforces the rest.
await hops you over: it compiles, and the result still resumes on main.
Rule 2: Results are values, await inline for control flow
Branch on the raw facts your flow cares about:When the call site can’t await
show(resume:) delivers every outcome, including .notPresented, on the main actor:
Sharing the result across the app
When other parts of the app need the outcome, forward it into an app-owned@Observable state object distributed via .environment(_:):
Rule 3: outcomes is for passive observers
Anything that wants to watch results without owning a call site consumes the multicastoutcomes stream. Every resolution lands there, plus late events:
outcomes returns an independent stream; any number of observers can listen concurrently.
Recipe: paywall-delegate call sites (Superwall and friends)
Delegate methods hand you a synchronous, nonisolated context. Bridge with aTask, forward the result into your state object:
Platform-specific notes
Task { }wrapping:show()isasync; SwiftUIButtonactions and UIKit@IBActionselectors are synchronous, so wrap the call inTask { ... }.show()never throws: failures arrive as.notPresented(.error(EncoreError)), read viaresult.error. There is nocatchblock to forget.Encoreis the entry point:Encoreis apublic final class. Access it viaEncore.shared; the staticEncore.placement(_:)forwards to it.- Purchases: there are no purchase handlers to register per call site. The
EncorePurchaseControllerpassed toconfigureowns every purchase.
See also
- Presenting Offers: the quickstart walkthrough
placement(),PresentationResult, andoutcomesin the SDK Reference