Skip to main content
This page adds both trigger components to your app in a few lines each: a Gifts Button at a reward moment and a Claim Reminder on a screen users come back to. Read Trigger components first if you want the picture before the code.

Before you start

  • Install the Encore SDK for your platform and call configure(), as in its quickstart: iOS, Android, React Native, Flutter, or Web.
  • Identify your user with identify() once you know who they are, as for show().
  • Pick a placement ID for each spot, such as milestone_reached for the end of a streak and home for your home screen. A trigger component opens the same reward sheet show() presents at that placement, so the placement works exactly as it does there.
A trigger component only appears when the reward sheet it opens has offers for this user. Until then it takes up no space, so you can add it to a screen and ship it before anything shows.

Add a Gifts Button

Put it on the screen where you would otherwise call show() for a reward, in place of that call:
That’s the whole setup. Encore picks the look, the copy, and the colors, and can change them without an app update. A tap opens the reward sheet for that placement.

Add a Claim Reminder

Put it on a screen users return to on their own, such as your home screen:
Claim Reminder shows a claim the user started but hasn’t finished. Until the SDKs can read the user’s open claims from Encore, which ships after the first trigger release, it shows only claims made in your app on this device. Adding it now is safe: with no claim to show, it takes no space and sends nothing.

Use your own words (optional)

Set the entry’s text with headline, subheadline and cta, as you do for the reward sheet. Leave any of them out and that line keeps the look’s own copy, in the user’s language:
Claim Reminder takes the same options. Your text says which looks show which line.

Pay your prize (optional)

If your app pays its own prize for trying an offer, pass it as publisherReward and read the result in onResult. See Pass your prize and read the result.

The trigger host

Each shorthand on this page is the trigger host with its ID built in. Use the host when your app places trigger components through one code path, for example from your own server-driven layout. It takes the trigger ID as a string:
An ID the SDK doesn’t know renders nothing, so a server that names a future trigger component can’t break an older app.

Parameters

The host and every shorthand take these by name. Every one except placement (and id on the host) is optional. The names of the typed values differ by platform: On the web, publisherReward, onResult and alignment go inside the options object you pass to mount(), and the handle’s setAlignment() moves a mounted trigger component.

Platform notes

  • iOS. The SDK installs on iOS 15, but trigger components draw only on iOS 17 or later. Below that they render nothing. EncoreTriggerView (UIKit) takes publisherReward and onResult as properties you set after creating it; GiftsButtonView(placement:) and ClaimReminderView(placement:) take them directly when you create them. Pin a UIKit view’s leading and trailing edges, not its height.
  • Android. Android 7.0 (API 24) or later. EncoreTriggerView’s constructor doesn’t take publisherReward, onResult or alignment; set them as properties. On GiftsButtonView and ClaimReminderView, alignment is a property too. On EncoreTriggerView the ID property is triggerId, because View.id is already the view’s integer ID. XML attributes carry an encore prefix: app:encoreTriggerId, app:encorePlacement, app:encoreUseCase, app:encoreIcon, app:encoreAlignment, and app:encoreAutoOpen. Use wrap_content for the height.
  • React Native. React Native 0.72 or later. The trigger components render the native trigger view, so they need the native module linked: in Expo Go, or with React Native for web, they render nothing and log one warning. A style sets the width and margins; the height always comes from the trigger component. When you read onResult, check result.status === 'presented' before reading result.claim.
  • Flutter. iOS 17 or later (the plugin installs on iOS 15), and Android API 26 or later. Android and iOS only: on the web and desktop the widgets render nothing. Give them a bounded width, as inside a Column or ListView.
  • Web. mount() returns a handle; call unmount() when you remove the element. The React components clean up for you and render inside the EncoreProvider from React. If you serve the SDK’s ES module build yourself, serve the whole dist/esm folder: trigger components load from its chunks folder on first use, so a page without them never downloads them.

Next steps