
柔軟な報酬ペイロード
報酬データはフリーフォーマットの JSON。ゲームが認識する通貨・アイテム・フラグの任意の組み合わせを付与できます。
サーバー上のプレイヤー値
引き換え時にサーバーが最大8種類の設定済み値を付与します。giftDataは別のゲームデータです。返された残高を表示し、ローカルで報酬を再加算しないでください。
即時無効化
コードが流出や不正利用された場合、Dashboard から即座に無効化できます。アプリのアップデートは不要です。
クイック統合
コード引き換え
ギフトコードを入力
プロモーションコードを下に入力してください
WINTER2024
// 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.これらの例では、Unity SDK(C#)とREST APIを使っています。GodotとUnrealでも、それぞれのSDKで同じ呼び出しができます: クイックスタートを参照
