XUserResolveIssueWithUiAsync

显示用于使用非 Unicode URL 解决令牌问题的系统用户界面。

语法

HRESULT XUserResolveIssueWithUiAsync(  
         XUserHandle user,  
         const char* url,  
         XAsyncBlock* async  
)  

参数

user _In_
类型:XUserHandle

具有令牌问题的用户的句柄。

url _In_opt_z_
类型:char*

对于 Xbox Live 问题,如果同意,则传递 nullptr。 否则,设置为创建问题的 Web 请求的 URL。

async _Inout_
类型:XAsyncBlock*

用于轮询调用的状态和检索调用结果的 XAsyncBlock

返回值

类型:HRESULT

如果成功,则返回 S_OK;否则返回错误代码。 有关错误代码的列表,请参阅错误代码

备注

要返回 XUserResolveIssueWithUiAsync 返回的结果,请调用 XUserResolveIssueWithUiResult。 如果 XUsers API 返回 E_GAMEUSER_RESOLVE_USER_ISSUE_REQUIRED 错误,则用户必须与系统用户界面 (UI) 交互来解决问题。 调用 XUserResolveIssueWithUiAsync 以显示相应的系统 UI。

要显示用于使用 Unicode URL 解决令牌问题的系统用户界面,请调用 XUserResolveIssueWithUiUtf16Async

下面的示例演示如何显示系统 UI 以使用 URL 解决令牌问题。

HRESULT ResolveUserIssueComplete(XAsyncBlock* ab)
{
    if (SUCCEEDED_LOG(XUserResolveIssueWithUiResult(ab)))
    {
        appLog.AddLog("Successfully Resolved User Issue\n");
    }

    return S_OK;
}

HRESULT ResolveUserIssueUtf16Complete(XAsyncBlock* ab)
{
    if (SUCCEEDED_LOG(XUserResolveIssueWithUiUtf16Result(ab)))
    {
        appLog.AddLog("Successfully Resolved User Issue\n");
    }

    return S_OK;
}

HRESULT ResolveUserIssueWithUiAsync(
    XTaskQueueHandle queue,
    const char* narrowUrl = nullptr,
    const wchar_t* wideUrl = nullptr,
    bool useUtf16 = false)
{
    auto resolveAsyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(resolveAsyncBlock.get(), sizeof(*resolveAsyncBlock));
    resolveAsyncBlock->queue = queue;
    resolveAsyncBlock->context = this;

    if (useUtf16)
    {
        resolveAsyncBlock->callback = [](XAsyncBlock* ab)
        {
            auto asyncBlock = std::unique_ptr<XAsyncBlock>(ab);
            LOG_IF_FAILED(static_cast<User*>(ab->context)->ResolveUserIssueUtf16Complete(ab));
        };

        if (SUCCEEDED_LOG(XUserResolveIssueWithUiUtf16Async(
            _handle.get(),
            wideUrl,
            resolveAsyncBlock.get())))
        {
            // The call succeeded, so release the std::unique_ptr ownership of XAsyncBlock* since the callback will take over ownership.
            // If the call fails, the std::unique_ptr will keep ownership and delete the XAsyncBlock*
            resolveAsyncBlock.release();
        }
    }
    else
    {
        resolveAsyncBlock->callback = [](XAsyncBlock* ab)
        {
            auto asyncBlock = std::unique_ptr<XAsyncBlock>(ab);
            LOG_IF_FAILED(static_cast<User*>(ab->context)->ResolveUserIssueComplete(ab));
        };

        if (SUCCEEDED_LOG(XUserResolveIssueWithUiAsync(
            _handle.get(),
            narrowUrl,
            resolveAsyncBlock.get())))
        {
            // The call succeeded, so release the std::unique_ptr ownership of XAsyncBlock* since the callback will take over ownership.
            // If the call fails, the std::unique_ptr will keep ownership and delete the XAsyncBlock*
            resolveAsyncBlock.release();
        }
    }

    return S_OK;
}

要求

头文件:XUser.h

库:xgameruntime.lib

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

另请参阅

XUser

XUserResolveIssueWithUiResult

XUserResolveIssueWithUiUtf16Async