
Crie códigos promocionais para o seu jogo
Configure códigos no painel para dar aos jogadores itens, moedas ou outras recompensas do jogo.
Payloads de recompensa flexíveis
Os dados da oferta são JSON de formato livre, pelo que pode conceder qualquer combinação de moedas, itens ou flags que o seu jogo compreenda.
Valores do jogador no servidor
O servidor credita até oito valores configurados no resgate. giftData continua separado dos valores do jogador. Mostre o saldo retornado sem adicionar a recompensa novamente no cliente.
Controlo de revogação
Revogue um código instantaneamente a partir do dashboard se for divulgado ou utilizado abusivamente, sem necessidade de atualizar a app.
Integração rápida
Resgatar código
Introduzir código de oferta
Introduza o seu código promocional abaixo
// Develop Unity SDK: signed-in player, durable original redemption intent.
using PM.horizOn.Cloud.Manager;
using UnityEngine;
// Run from one explicit player action; serialize this handler until it completes.
string userId = UserManager.Instance.CurrentUser.UserId;
string project = HorizonApp.Network.GetApiKey();
string scope = PM.horizOn.Cloud.Objects.Network.Responses.GiftCodeIntent.ProjectFingerprint(project);
string pendingKey = "horizOn_gift_v2_" + scope + "_" + userId;
// Preserve an old V1 demo record for reconciliation. Never reinterpret its UUID as a count.
if (PlayerPrefs.HasKey("horizOn_gift_pending_" + userId)) return;
PM.horizOn.Cloud.Objects.Network.Responses.GiftCodeIntent pending;
if (PlayerPrefs.HasKey(pendingKey)) {
pending = JsonUtility.FromJson<PM.horizOn.Cloud.Objects.Network.Responses.GiftCodeIntent>(PlayerPrefs.GetString(pendingKey));
if (pending == null || !pending.IsValidFor(project, userId)) return;
} else {
pending = await GiftCodeManager.Instance.PrepareRedemption("WELCOME");
if (pending == null || !pending.IsValidFor(project, userId) || PlayerPrefs.HasKey(pendingKey)) return;
PlayerPrefs.SetString(pendingKey, JsonUtility.ToJson(pending));
PlayerPrefs.Save(); // All seven fields before the first mutating request.
}
string original = JsonUtility.ToJson(pending);
if (PlayerPrefs.GetString(pendingKey) != original) return;
var result = await GiftCodeManager.Instance.RedeemPrepared(pending);
if (result == null || !result.success) return; // Keep the exact tuple after any uncertain result.
if (PlayerPrefs.GetString(pendingKey) == original) {
PlayerPrefs.DeleteKey(pendingKey);
PlayerPrefs.Save();
}
if (result.playerValues != null) {
foreach (var value in result.playerValues.values) Debug.Log(value.key + "=" + value.balance);
}
// alreadyApplied/replayed means the sequence slot was consumed, with no copied historical rewards.
// Replace balances with playerValues. Never add grantedValues locally.Estes exemplos usam o SDK do Unity (C#) e a API REST. Godot e Unreal têm as mesmas chamadas nos seus próprios SDKs: veja o quickstart
Perguntas frequentes
Pronto para integrar?
Comece a construir com o horizOn hoje. Tier gratuito incluído.
