Skip to main content
Requires SDK 2.4.0+ on every platform. See Minimum SDK versions.
Gifts Button and Claim Reminder are the recommended way in: one line each, and Encore can change and test their looks without an app update. When your design needs the entry drawn in your app’s own style, draw it yourself instead of skipping the entry. Encore still does everything behind it: it decides when the entry should show and what it shows, counts each view and tap, opens the reward sheet, and hands you the result. After a claim, your entry can turn into a reminder for that claim (it does by default), as Gifts Button does. Everything on Trigger components about the reward sheet, claims, and analytics applies. What differs: you draw it, so Encore’s looks, heights, copy, and colors don’t apply.

How it works

You create one claim handle per placement and read its state. The state says what to draw: You attach your view to the handle. Encore then counts a view when at least half of it is on screen for one second with no sheet over it. On iOS, Android, React Native and the web, a tap on the attached view opens the reward sheet for that placement; on Flutter, call claim.tap() from your view. A tap while the state is hidden does nothing. The state changes on its own: by default it turns into the reminder after the user claims an offer and back into gifts when the claim is finished, its 24 hours end, or the user dismisses it, and to hidden when the offers run out. Encore can change what follows a claim and a completion (below). Redraw whenever it changes.

Add it

The options are placement (required), useCase, autoOpen, publisherReward, and onResult. Encore decides what comes next. As with Gifts Button, Encore sets what your entry shows after a claim and after a completion, and can test it, without an app update. After a claim the state can turn into reminder or stay gifts; after a completed claim it can be gifts, hidden, or thanks. Draw every state and your entry follows. When Encore’s rules can’t be read, a claim turns the state into reminder and a completion turns it back into gifts, as by default, so a failed rules request never hides your entry. If the offers themselves can’t be read, the state is hidden, as for the drop-in trigger components. Opening by itself. Encore may open the reward sheet by itself when a test calls for it: at most once a day per placement, only after your view was really on screen, only while your app is in the foreground, and never over another Encore sheet. Set autoOpen to off to never: autoOpen: .off on iOS, AutoOpen.OFF on Android, AutoOpen.off on React Native, EncoreAutoOpen.off on Flutter, and 'off' on the web. On Android, claim.state is a Compose state, so a Compose view that reads it redraws on every change; outside Compose, collect claim.stateFlow. For Views or code outside Compose, make the handle with Encore.claim(placement = "streak"), attach a view with claim.bind(view), and call claim.close() when you no longer need it. rememberEncoreClaim closes its handle when it leaves the composition. The reminder state also carries perk, the offer’s perk as the sheet showed it.

Show your entry only when there are offers

A user should never keep seeing an empty entry. Some users have no offers: for example, when your app passed the user’s age as under 18 and every offer at the placement is rated 18+, because Encore serves a user known to be under 18 only offers rated for their age. Encore’s own trigger components hide themselves then. An entry you draw must hide too. Recommended: use Encore.claim. It loads the offers in the background without opening anything, so you draw your entry only while the claim has offers. From 2.5.0, claim.hasOffers says so in one value. On 2.4.0, draw while claim.state isn’t hidden, as Add it does on every platform. From 2.5.0, one rule covers every entry:
  • A button you draw: Encore.claim. Draw the button only while claim.hasOffers is true.
  • A sheet from your own flow: Encore.placement. Ask hasOffers() before you show the item that opens the sheet, such as a “Get a gift” row at the end of a level.
A button that stays on screen should use the claim, because a placement answers once, at the moment you ask.

With hasOffers, from 2.5.0

hasOffers is available from 2.5.0 of the iOS, Android, and web SDKs. On 2.4.0, draw while claim.state isn’t hidden, as Add it does. On earlier versions, use the pattern for those versions.
On a claim, claim.hasOffers is true when the last check found at least one offer. It is false while the state is hidden: before the first check, after a failed check, and when no offer fits the user. On iOS, hasOffersPublisher sends the same value for UIKit and Combine. On Android, hasOffersFlow is the same value as a StateFlow for Views. On the web with React, claimHasOffers(state) reads it from the state of useEncoreClaim.
On a placement, await placement(id).useCase(rewardUsers).hasOffers() answers whether show() would find reward offers for this user now. Chain the reward use case: the builder’s default is the churn use case, and on it hasOffers() always answers false. Any failure also answers false. It never throws. Ask when you decide to show the item, not once at app start.
On Android, hasOffers { result -> } is the callback form. It calls you once, on the main thread. Keep the item hidden until hasOffers() answers, as the samples do, so no tap opens the sheet before the check. After true, the next show() usually uses the same offers and makes no second search. A false stays for up to 5 minutes, so asking often sends no extra requests; a new user, new user attributes, or a new language ask again. React Native and Flutter don’t have hasOffers yet. Use the claim state, as in Add it.

Without an SDK update

On 2.3.1 and earlier (2.3.0 and earlier on the web), there’s no way to check for offers without opening the sheet: show() opens it right away whenever there are offers. So never call show() at launch or when a screen appears to check for offers. Draw your button, call show() only from its tap, and when that tap comes back with no offers, hide the button for the rest of the session. The user still sees one empty tap. Keep the flag in state that lasts for the session, not in a view that is rebuilt. Clear it when the app restarts and when the user changes, on identify() or reset(), because offers are per user.
On the web, unavailable also means a measurement control cohort, no sheet for the use case, or a failed request for the sheet’s settings. So on the web, one network error can also hide the button until the flag clears. On React Native, the result is not_presented and reason.type is no_offer_available. On Flutter, it is EncoreNotPresented with reason noOffers. The result types are in each SDK’s reference: iOS, Android, web, React Native, Flutter.

A view with its own buttons

When your view has buttons of its own, such as a close button on your reminder, don’t let the whole view open the sheet. Report what’s visible and call the tap yourself:
  • iOS and Android: pass handlesTap: false to the modifier (on an Android View, claim.bind(view, handlesTap = false)), and call claim.tap() from your own button. On iOS, tap() returns the sheet’s result; on Android, pass onDone to get it, as in claim.tap(onDone = { result -> }). To grant a prize, use onResult instead (see Pass your prize and read the result).
  • React Native: pass handlesTap={false} to EncoreClaimView, and call tap() from useEncoreClaim in your own button.
  • Flutter: EncoreClaim never opens the sheet from a tap by itself; call claim.tap() from your own buttons, with target: EncoreClaimTarget.card for a reminder card. It returns the sheet’s result.
  • Web: bind(element, { tap: false }) counts the whole element’s visibility and leaves taps to you; call claim.tap() from your button. In React, pass tap: false to useEncoreClaim and put ref on the element. Even with taps on, a click that starts on a control inside the bound element, such as your close button, never opens the sheet.
Keep your own buttons inside the same check as the entry, so they never show while the claim has no offers. See Show your entry only when there are offers. claim.dismiss() hides the reminder, every claim it was showing, on this device. Call it from your close button. It does nothing while the state isn’t reminder.

Pass your prize and read the result

Pass publisherReward and onResult when you create the handle, as for Gifts Button. onResult is called once per sheet the handle opens, after the sheet closes, whether the tap came from your attached view or from your own claim.tap(). The result tap() returns is the same one, so grant your prize in onResult only, or an app that grants from both pays twice. The grant rule is the same as for Gifts Button. Everywhere but the web, grant when userConfirmedCompletion is true on the result’s claim, keyed on the transaction ID. On the web, keep the claim’s transactionId and grant when the offer_completed webhook confirms it.

Accessibility

You own the labels. When the handle takes the tap, each platform makes your view one control, and you give it a label that says what a tap does:
  • iOS: .encoreClaim(claim) adds the button trait to the view it modifies. On a stack with several children, SwiftUI passes that trait to each child, so VoiceOver reads every text and image as a separate button. Combine the children into one element and label it, before the modifier:
    With handlesTap: false the modifier adds no trait, so your own buttons, such as a close button, stay separate elements.
  • Android: Modifier.encoreClaim(claim) makes the view one clickable element with the button role, and TalkBack reads its children’s text as one label. When that text doesn’t say what a tap does, add a contentDescription with Modifier.semantics. On an Android View, claim.bind(view) only sets a click listener, so set the view’s contentDescription yourself.
  • React Native: EncoreClaimView wraps your children in one Pressable with the button role. Pass it accessibilityLabel.
  • Flutter: EncoreClaim adds no semantics, because your own widgets call claim.tap(). Wrap an entry made of several widgets in MergeSemantics, or in Semantics(button: true, label: ...).
  • Web: bind(element) makes an element that isn’t already a button or link behave like one: it adds role="button", lets it take keyboard focus, and opens the sheet on Enter and Space. Give it an aria-label when its text isn’t enough.

Testing your states

Draw every state, then check each one on a debug build with your test API key (pk_test_…), which serves a demo catalog:
  • gifts: shows once the reward sheet at your placement has offers. On the test key it does.
  • hidden: shows at a placement whose sheet has no offers, and before configure(). Check that your screen looks right without the entry.
  • reminder: open the sheet from your entry and claim an offer. The test key lets the claim go through without a live campaign. Back in your app, the state turns into reminder for 24 hours. Your close button’s claim.dismiss() turns it back into gifts.
  • thanks: opt-in on Encore’s side. After a completion the default is gifts, so you see thanks only once Encore turns it on for your app. Ask your Encore contact to turn it on for your test app if you want to check it.
Claims are kept per user on the device. To start over, identify() a new test user. The SDKs have no public hooks for adding or clearing claims.

Experiments and analytics

Encore can test what your entry does after a claim and after a completion, as it tests the drop-in trigger components. The reward sheet it opens takes part in its own experiments too: when the sheet’s experiment holds a user out, the state is hidden. Encore reports your entry’s views, taps, and dismissals as it does for its own trigger components, marked as your own button. You don’t send any events.
Don’t also mount a Gifts Button or Claim Reminder at the same placement and screen as your own entry: the user would see two entries for one sheet.