Skip to main content
Gifts Button is a trigger component: a “you have a gift” entry you place at a reward moment in your app, for example right after the user finishes a streak. Instead of your app opening the reward sheet on its own, the user sees the entry and opens the sheet when they choose to. Tapping it opens the same reward sheet that show() presents for that placement, with the same premium brand offers, each one a real perk a brand funds to acquire customers. Its trigger ID is giftsButton. Everything on Trigger components applies to it. This page covers only what is specific to Gifts Button.
Requires SDK 2.4.0+ on every platform. See Minimum SDK versions.

When to use it

Use Gifts Button on the screen where you would otherwise call show() for a reward, for example the screen that celebrates a finished streak. Mount it there in place of your own show() call for that moment, not as well as it. Keeping both can present the sheet twice. Its use case defaults to the reward use case, so leave useCase out. Churn isn’t supported yet: with the churn use case, Gifts Button renders nothing.

What the user sees

  • An entry, only when there’s a gift. Gifts Button checks for offers for its use case and placement, the same check show() makes before it presents. With no offers, it renders nothing. If you draw your own button, it must hide too: see Show your entry only when there are offers.
  • A tap opens the reward sheet. The sheet is the normal one for that use case and placement, as if your app had presented it.
  • It stays while offers remain. When the sheet closes, Gifts Button checks again and hides only when no offers are left. The user can’t dismiss it.
  • It may open the sheet once by itself. When an Encore test calls for it, Gifts Button can open its sheet on its own: at most once a day at each placement, only while your app is in the foreground, and never over another Encore sheet. It also waits while your app has the gift locked. Set autoOpen to off to stop it.

Place it in your layout

Use the GiftsButton shorthand for your platform. Give it a placement ID and, optionally, your appearance, which colors the entry and never the sheet it opens. Encore picks the look:
Each shorthand is the trigger host with the ID giftsButton. The parameters table gives every default.

The moment

From SDK 2.7.0 (on Flutter and React Native, the release that requires native 2.7.0), Gifts Button takes a moment: why it shows now, so Encore learns which offers fit. See Add the moment.

Your text

Pass headline, subheadline and cta to put your own words on the entry, such as the name of the moment the user just reached:
Any line you leave out shows the look’s own copy, in the user’s language, and every look Encore tests falls back to its own words. A look shows your cta only when it draws a button or a label, as banner and pill do. See Your text for the rules on length and line breaks.

Looks

Encore picks the look, and can test several against each other. These are the looks it serves today. It draws each one from a look file it can change without an app update, so treat the heights as defaults rather than constants. Heights are in points on iOS, dp on Android, and CSS pixels on the web. Each look is one control, named for assistive technology by its copy. The pulse animation and the scrolling logos of offerMarquee and offerColumns pause while the entry is off screen and stay still when the user has reduced motion turned on.

Pass your prize and read the result

When your app pays its own prize for trying an offer, pass it to Gifts Button as publisherReward. It is the same value you would pass to placement(id).publisherReward(...) before show(), with the same rules: a PublisherReward on iOS, Android, and React Native, and an EncorePublisherReward on Flutter. On the web it is a PublisherReward with the same fields: id, title, and the optional detail and iconUrl. Gifts Button hands it to every sheet it opens. Pass onResult to receive the result of each sheet Gifts Button opens. It is called once per sheet, after the sheet closes, with the same result show() returns. Both are optional; without them Gifts Button behaves exactly as described earlier on this page. On iOS, Android, React Native, and Flutter, grant the prize from onResult only, when userConfirmedCompletion is true on the result’s claim, with this grant key: the transaction ID, or your user ID plus campaignId when it is missing.
On the web, the sheet doesn’t show or grant your prize yet. Gifts Button accepts publisherReward and passes it to the sheet, but the web sheet doesn’t draw the promise or ask whether the user finished, and its result (a ShowResult) has no userConfirmedCompletion flag. A claimed result only means the user went to the brand, so never grant from it. Keep the claim’s transactionId from onResult, as the web sample does, and grant from your server when the offer_completed webhook with that transaction ID confirms the completion.

Other ways to learn about a claim

onResult is the main path, because it belongs to this one entry. Two other channels see the same claims: Pay the prize from one place only. The outcomes stream carries the same result onResult receives, so an app that grants from both pays twice.
Changing publisherReward on a mounted Gifts Button applies to the next sheet it opens.

Host state

Coming soon. Host state is planned for iOS 2.6.0 and Android 2.6.0, which aren’t released yet. React Native, Flutter, the web SDK and Unity don’t take a host state yet.
Sometimes the gift should unlock only after the user does something in your app, such as reaching a goal. Only your app knows when that happens, so your app passes it to the Gifts Button as a host state. A host state has a status and, while locked, an optional progress: Pass the progress smoothly, as a fraction from 0 to 1, or as steps, such as 3 of 4. Steps become completed divided by total, so 3 of 4 is the same as a progress of 0.75, and a total of 0 or less means no progress. Either way, progress is clamped to 0 to 1, and a value that isn’t a finite number counts as no progress. The look decides how its ring draws the progress: as a smooth fill, or in whole segments. A look that fills whole segments uses its own segment count, not your total. If you pass steps and want the ring to show exactly that many pieces, ask your Encore contact to set the tile’s segment count to your total. Set the host state when you place the Gifts Button and change it whenever your app’s state changes:
The statuses are .locked(progress:) or .locked(completed:of:), .ready and .done on iOS, and GiftsButtonHostState.locked(progress) or GiftsButtonHostState.locked(completed, total), GiftsButtonHostState.Ready and GiftsButtonHostState.Done on Android. progress is optional on both. Set the host state to nil or null, or leave it out, and the Gifts Button behaves exactly as the rest of this page describes. What a host state changes:
  • A locked tap opens nothing. Whatever the look draws, a tap while locked never opens the sheet and sends no click event, so taps that opened nothing never count as taps. The look can answer the tap with a short hint, such as a nudge of its ring.
  • No opening by itself while locked. A look that opens the sheet once by itself waits while the status is locked. Once the status is ready or done, the usual once-a-day rule applies.
  • It stays on the device. The host state is never sent in a request or stored. Changing it redraws the entry in place, with no new request. Only the status word (locked, ready or done) goes on the entry’s analytics events, and only while you set a host state. The progress never leaves the device.
  • A new status is a new impression. Going from locked to ready counts a new impression with the new status. A progress change doesn’t.

Draw your own view when the button shows nothing

Pass onShowingChange to learn whether the Gifts Button is drawing a look. It is called on the main thread with true while a look shows and false while the entry draws nothing, for example because there are no offers or the user is in a holdout group. It is called once the Gifts Button first has an answer for the user, then on each change. Use it to draw your own view in the same spot when Encore draws nothing. Keep the Gifts Button mounted, since an empty one takes no space, and show your own view until it answers: it isn’t called before configure(), so a Gifts Button that never gets an answer never calls it.
On iOS it is the .onShowingChange(_:) modifier in SwiftUI and the onShowingChange property of GiftsButtonView in UIKit. On Android it is the onShowingChange parameter of GiftsButton in Compose and the onShowingChange property of GiftsButtonView. You can set either property at any time.

Tile look

Coming soon. Encore doesn’t serve the tile look or its segmented ring yet. Both need iOS 2.6.0 or Android 2.6.0.
The tile is a look made for host state, sized for a half-width slot in a two-column grid. While locked it draws a ring around the gift that fills with progress, and a line of text under it. When ready, or with no host state, it draws a full ring and opens the sheet on a tap. When done it draws a full ring with its done text.
  • It fills the width you give it. Give it the width of its grid slot and leave the height to it.
  • Its height follows its width. The tile sets its height from its own aspect ratio, so it is taller than it is wide. Its height is capped at 320 points on iOS and 320 dp on Android. On a wide screen it reaches the cap and its content stays centered.
  • Your headline replaces the locked line. Leave it out and the tile shows its own copy. See Your text.
Encore can also split the tile’s ring into segments: separate arcs with a gap between them, for example 2 of them. Progress fills them in order, clockwise from 12 o’clock: with 2 segments at a progress of 0.5, the right arc is full and the left one is empty. By default a segment fills gradually as progress grows; Encore can instead show each segment only once it is complete. These are settings of the look, not of your code, so ask your Encore contact for the segment count you want. Encore picks the look for each placement, as for every other look. To use the tile, ask your Encore contact to switch your placement to it.

After a claim

Encore decides what the spot shows after the user claims an offer, and can test the choices against each other. Usually Gifts Button turns into a Claim Reminder: the same spot reminds the user to finish that claim, with a countdown, and a tap opens the reward sheet with that offer in it. It turns back into Gifts Button when any of these happens:
  • The claim is completed. Encore confirms the user finished it.
  • The reminder window ends. That is 24 hours after the claim by default; Encore sets it with the look.
  • The user taps ×. Every claim it was reminding about is hidden on this device. A claim made later brings the reminder back.
  • The offer leaves the sheet. For example, the brand paused the campaign, or the campaign reached its cap.
Any claim the user makes in an Encore sheet counts, including one from your own show() call, as long as this placement’s sheet still lists that offer. The SDK keeps the user’s claims on the device, so the reminder also shows after the app reopens, until one of those four things ends it. The spot’s request for its look includes whether a claim is open, so Gifts Button doesn’t flash first. A claim counts as open while it’s inside the reminder window last served at this placement, which the device remembers across launches; until one is served there, that’s 24 hours. The reminder in the spot keeps its own look and analytics. Don’t also mount a Claim Reminder at the same spot: the user could see the reminder twice. The height changes. Reminder looks are 76 points tall (pixels on the web), and the featured look is 85. Gifts Button’s looks are 48 to 112. The entry takes its new height at once while the content fades across, so leave room in your layout for it to grow or shrink.

After a completion

A claim is completed when Encore confirms the user finished the offer. On iOS and Android, a user telling the sheet they finished it counts too. An expired or failed claim is not a completion. The entry asks Encore about the user’s newest open claims when the screen opens and when the app comes back to the foreground, so a completed claim stops showing as a reminder. After a completion, Encore decides what the spot shows for the rest of the user’s day, and can test the choices against each other:
  • Gifts Button while its sheet has offers, as before.
  • Nothing, until midnight on the user’s device or until they claim another offer, whichever comes first.
  • A thanks look: “Nice work, you finished it” with “More gifts are waiting” and a “See gifts” button, and no logos. A tap opens the reward sheet as Gifts Button does, and the spot goes back to Gifts Button. So do a new claim and midnight on the user’s device. Its events carry the layout thanks.
There is nothing to set: the behavior comes with the look Encore serves.

What Encore controls

The served look sets the layout, the height, the copy (in the user’s language) for each line you don’t set yourself, the default colors, and what the spot shows after a claim and after a completion. Encore can test several looks against each other, so different users can see a different entry. Your appearance colors always win, in the color order. The entry never names the reward.

Analytics

Gifts Button reports its own impressions and taps to Encore’s analytics. You don’t send any events. While you set a host state, its events also carry the status, never the progress.