> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XUserResolveIssueWithUiAsync

> XUserResolveIssueWithUiAsync

# XUserResolveIssueWithUiAsync

顯示系統使用者介面，以解決非 Unicode URL 的權杖問題。

## 語法

```cpp theme={null}
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\*](/zh-TW/reference/system/xasync/structs/xasyncblock)

用於輪詢呼叫狀態並擷取呼叫結果的 [XAsyncBlock](/zh-TW/reference/system/xasync/structs/xasyncblock)。

### 傳回值

類型：HRESULT

如果成功，則傳回 S\_OK；否則傳回錯誤碼。如需錯誤碼清單，請參閱[錯誤碼](/zh-TW/reference/errorcodes)。

## 備註

若要傳回 XUserResolveIssueWithUiAsync 所傳回的結果，請呼叫 [XUserResolveIssueWithUiResult](/zh-TW/reference/system/xuser/functions/xuserresolveissuewithuiresult)。
如果 XUsers API 傳回 E\_GAMEUSER\_RESOLVE\_USER\_ISSUE\_REQUIRED 錯誤，使用者必須與系統使用者介面 (UI) 互動以解決問題。
請呼叫 **XUserResolveIssueWithUiAsync** 以顯示適當的系統 UI。

若要顯示系統使用者介面以解決 Unicode URL 的權杖問題，請呼叫 [XUserResolveIssueWithUiUtf16Async](/zh-TW/reference/system/xuser/functions/xuserresolveissuewithuiutf16async)。

下列範例示範如何顯示系統 UI，以解決 URL 的權杖問題。

```cpp theme={null}
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、Steam Deck、XBOX One 系列主機和 XBOX Series 主機

## 概念文件

* [使用 Game Chat 2 C++ API](/zh-TW/services/xbox-services/multiplayer/chat/game-chat2/using-game-chat-2)

## 另請參閱

[XUser](/zh-TW/reference/system/xuser/xuser_members)

[XUserResolveIssueWithUiResult](/zh-TW/reference/system/xuser/functions/xuserresolveissuewithuiresult)

[XUserResolveIssueWithUiUtf16Async](/zh-TW/reference/system/xuser/functions/xuserresolveissuewithuiutf16async)


## Related topics

- [XUserResolveIssueWithUiAsync](/reference/system/xuser/functions/xuserresolveissuewithuiasync.md)
- [XUserResolveIssueWithUiResult](/reference/system/xuser/functions/xuserresolveissuewithuiresult.md)
