react-native-encore-mock
Documentation for react-native-encore-mock — a
mock-first integration kit for Encore, the retention-offer & entitlement SDK
(@tryencorekit/react-native).
It lets you build, demo, and test Encore’s offer flow — retention discounts, brand-sponsored partner trials, and entitlements — with zero native dependencies, then switch to the real SDK by flipping one constant.
This is a temporary mock for demonstration only. react-native-encore-mock is
not the real Encore SDK — it’s an in-memory stand-in built for a demo, and it
will be deleted after the demonstration. Don’t build anything that depends on it.
The working example throughout these docs is Hotspot Havoc, an Expo React Native game that consumes the package.
What is Encore?
Encore presents targeted offers at key moments and tracks the entitlements that result:
- A user starts a cancellation flow → Encore presents brand-sponsored offers (Disney+, Netflix, Spotify…) where a partner pays for the user’s subscription — Encore’s Brand-Sponsored Premium Trials.
- A user hits a feature paywall → Encore offers a paid trial or discount.
Your app asks Encore to present an offer at a placement; Encore decides what (if anything) to show and reports the result. Encore never charges the user — for paid offers your billing library (RevenueCat, react-native-iap, StoreKit, Play Billing) performs the purchase; for sponsored offers the partner brand foots the bill.
What the package gives you
| Export | Purpose |
|---|---|
createMockEncore(config?) | In-memory client implementing Encore’s full surface |
MockEncoreProvider | Hosts the offer UI — retention sheet + sponsored partner carousel |
useEncoreCallbacks(encore, opts) | Registers the 3 callbacks; enforces the completePurchaseRequest rule |
isGranted(result) | true for a paid (granted) or sponsored (completed) win |
DEFAULT_OFFERS, DEFAULT_PARTNERS | Ready-made offer + partner presets |
| Types | EncoreClient, PlacementResult, MockOffer, PartnerTrial, … |
The flow you wire is the real one:
<MockEncoreProvider> → Encore.identify() → useEncoreCallbacks()
→ Encore.placement(id).show() → isGranted(result) → entitle the userGoing live is a one-line change — flip USE_MOCK and the same code talks to the
real native @tryencorekit/react-native.
Where to go next
- Getting Started — install and wire it up.
- Architecture — how the pieces fit + the data-flow diagram.
- Integration Walkthrough — every step with code and the why.
- Sponsored Offers — brand-sponsored partner trials at cancellation.
- Mock vs Live Mode — the
USE_MOCKswitch and going live. - Customizing for Production — real billing, real placements, clean logs.
- Troubleshooting / FAQ — the must-know gotchas.