Skip to main content

XUserAddByIdWithUiAsync

Asynchronously adds a user to a game session based on a XUID from a game invite. This function should only be used in response to a game invite.

Syntax

Parameters

userId   _In_
Type: uint64_t
XUID of the user to add. This XUID should be obtained by parsing the inviteUri received in the game’s callback that was registered with XGameInviteRegisterForEvent. async   _Inout_
Type: XAsyncBlock*
An XAsyncBlock for polling for the call’s status and retrieving call results.

Return value

Type: HRESULT HRESULT success or error code. For a list of error codes, see Error Codes.

Remarks

XUserAddByIdWithUiAsync starts an asynchronous operation to add a user to the game. Use XUserAddByIdWithUiResult to retrieve the results of the operation. When dealing with game invites, there is always the possibility on console that the XUID of the person specified in the game invite isn’t the person who is already signed into the game. The XUserAddByIdWithUiAsync allows the game to add that user using the XUID that is parsed from the invite URI. This function will attempt to add the user without showing UI. The only reason UI may show is because the user needs to resolve an issue with their token. On console, showing UI should be uncommon. If the user is not signed into the device, XUserAddByIdWithUiResult will return E_GAMEUSER_USER_NOT_FOUND. You must close each XUserHandle handle you retrieve from an XUsers API only once by calling XUserCloseHandle. In order to get game invites, developers must subscribe to the XGameInviteCallback by calling XGameInviteRegisterForEvent. When this callback is invoked, games should parse the inviteUri they get back and determine the XUID of the user who is getting that invite. At that point, the game may want to get an XUserHandle for the person getting the invite. The following code demonstrates how this works.

Requirements

Header: XUser.h Library: xgameruntime.lib Supported platforms: Windows, , Steam Deck, XBOX One family consoles and XBOX Series consoles

See also

XUser
XUserCloseHandle
Last modified on August 20, 2026