Skip to main content
The backend can instruct the game to grant in-game rewards. Subscribe, credit the player, celebrate:
There is nothing extra to start. Grants travel with notifications, so FetchNotifications() fetches them and StopNotificationPolling() suspends them.

One event per grant

A grant is an atomic bundle. “250 gems and 3 spins for finishing the chapter” arrives as a single event with one id and two entries in Rewards. Show one celebration for it. Three separate grants arriving together raise three events. Amount is a double and may carry fractions, so do not truncate it to an integer. Code is the reward code agreed with Almedia, for example "gems". Treat a code you do not recognize as a no-op rather than an error.

Delivery is at-least-once

The same grant can arrive more than once. The server-to-server reward postback remains the authoritative record of what was granted; reconcile against it if your economy needs certainty. Each grant has a unique Id, and a redelivery carries the same one. Deduplicate on it when a repeat credit matters:
A short memory of recent ids is enough.

Testing without a backend

AlmediaEditorMock.EmitInGameRewardGrant delivers a grant to your handler. Call it twice with one id to reproduce a redelivery and prove your dedup holds:
See Driving non-happy paths for the mock’s rules.