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
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.
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: falseto the modifier (on an Android View,claim.bind(view, handlesTap = false)), and callclaim.tap()from your own button. On iOS,tap()returns the sheet’s result; on Android, passonDoneto get it, as inclaim.tap(onDone = { result -> }). - React Native: pass
handlesTap={false}toEncoreClaimView, and calltap()fromuseEncoreClaimin your own button. - Flutter:
EncoreClaimnever opens the sheet from a tap by itself; callclaim.tap()from your own buttons, withtarget: EncoreClaimTarget.cardfor 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; callclaim.tap()from your button. In React, passtap: falsetouseEncoreClaimand putrefon 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.
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.
Accessibility
You own the labels. On the 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. On iOS and Android the modifier adds the button trait when it handles the tap.
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 ishidden.
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.
Related
- Gifts Button: Encore’s own gifts entry, and what happens after a claim.
- Claim Reminder: what the reminder shows, and when.
- Trigger components: what every trigger component shares.