XStoreShowRedeemTokenUIAsync

针对指定的代币,触发当前用户的代币兑换。

语法

HRESULT XStoreShowRedeemTokenUIAsync(  
         const XStoreContextHandle storeContextHandle,  
         const char* token,  
         const char** allowedStoreIds,  
         size_t allowedStoreIdsCount,  
         bool disallowCsvRedemption,  
         XAsyncBlock* async  
)  

参数

storeContextHandle _In_
类型:XStoreContextHandle

XStoreCreateContext 返回的用户的应用商店上下文句柄。

token _In_z_
类型:char*

要兑换的代币。 此值不能为空或 null,如果您想要显示 UI 但不提供代码以预填充 UI,则在单一空格“ ”中传递。

allowedStoreIds _In_z_count_ (allowedStoreIdsCount)
类型:char**

允许您限制 5x5 代码以仅适用于特定产品。

allowedStoreIdsCount _In_
类型:size_t

allowedStoreIds 中的元素数。

disallowCsvRedemption _In_
类型:bool

防止兑换 CSV (礼品卡/货币样式 5x5s) 。

async _Inout_
类型:XAsyncBlock*

用于定义正在进行的异步工作的 XAsyncBlockXAsyncBlock 可用于轮询调用的状态和检索调用结果。 有关详细信息,请参阅 XAsyncBlock

返回值

类型:HRESULT

HRESULT 成功或错误代码。

备注

要检索此函数的执行结果,请在调用此函数后调用 XStoreShowRedeemTokenUIResult

以下代码段显示一个启动代币兑换 UI 的示例。

void CALLBACK ShowRedeemTokenUICallback(XAsyncBlock* asyncBlock)
{
    HRESULT hr = XStoreShowRedeemTokenUIResult(asyncBlock);

    if (FAILED(hr))
    {
        printf("Failed redeem token: 0x%x\r\n", hr);
        return;
    }
}

void ShowRedeemTokenUI(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle, const char* token)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;
    asyncBlock->context = taskQueueHandle;
    asyncBlock->callback = ShowRedeemTokenUICallback;

    HRESULT hr = XStoreShowRedeemTokenUIAsync(
        storeContextHandle,
        token,
        nullptr,    // Can restrict to specific store IDs
        0,
        false,      // Can prevent CSV (cash gift cards)
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to request redeem token: 0x%x\r\n", hr);
        return;
    }

    // Wait a while for the callbacks to run
    Sleep(5000);
}


要求

头文件:XStore.h(包含在 XGameRuntime.h 中)

库:xgameruntime.lib

支持平台:Windows、Xbox One 系列主机和 Xbox Series 主机

另请参阅

XStore
XStoreShowRedeemTokenUIResult