> ## 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.

# XGameInviteEventCallback (deprecated)

> XGameInviteEventCallback (deprecated)

# XGameInviteEventCallback (deprecated)

<Info>This API is now deprecated. Use [XGameActivationCallback](/reference/system/xgameactivation/functions/xgameactivationcallback) instead.</Info>

A callback an application defines for a game invite event.

## Syntax

```cpp theme={null}
void XGameInviteEventCallback(  
         void* context,  
         const char* inviteUri  
)  
```

### Parameters

*context*   \_In\_opt\_\
Type: void\*

The context we pass to [XGameInviteRegisterForEvent](/reference/system/xgameinvite/functions/xgameinviteregisterforevent).

*inviteUri*   \_In\_\
Type: char\*

The URI for joining the game session.\
<Note>XSAPI knows how to consume the URI.</Note>

### Return value

Type: void

<a id="ID_XGameInviteEventCallback_Remarks" />

## Remarks

To register a callback for a game invite event, call [XGameInviteRegisterForEvent](/reference/system/xgameinvite/functions/xgameinviteregisterforevent). The function uses a pointer to an **XGameInviteEventCallback** as an argument.

To unregister a callback for a game invite event, call [XGameInviteUnregisterForEvent](/reference/system/xgameinvite/functions/xgameinviteunregisterforevent).

The following code sample registers for a game invite callback.

```cpp theme={null}
#include <XTaskQueue.h>
#include <XGameInvite.h>  
  
XTaskQueueHandle g_taskQueue;  
XTaskQueueRegistrationToken g_gameInviteEventToken;  
  
void OnGameInvite(void* context, const char* inviteUri)  
{  
    if (inviteUri != nullptr)
    {
        std::string inviteString(inviteUri);
        auto pos = inviteString.find("handle=");
        auto inviteHandeId = inviteString.substr(pos + 7, 36);
        // Now call XblMultiplayerManagerJoinLobby if using MPM
        // or call XblMultiplayerWriteSessionByHandleAsync if using MPSD APIs
    }
}  
  
void InitializeGame()  
{  
    XGameInviteRegisterForEvent(g_taskQueue, nullptr, OnGameInvite, &g_gameInviteEventToken);  
}  
  
void ShutdownGame()  
{  
    XGameInviteUnregisterForEvent(g_gameInviteEventToken);  
}  
```

## Requirements

**Header:** XGameInvite.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## See also

[XGameInvite](/reference/system/xgameinvite/xgameinvite_members)

[XGameInviteRegisterForEvent](/reference/system/xgameinvite/functions/xgameinviteregisterforevent)

[XGameInviteUnregisterForEvent](/reference/system/xgameinvite/functions/xgameinviteunregisterforevent)


## Related topics

- [XGameInviteUnregisterForEvent (deprecated)](/reference/system/xgameinvite/functions/xgameinviteunregisterforevent.md)
- [XGameInviteRegisterForEvent (deprecated)](/reference/system/xgameinvite/functions/xgameinviteregisterforevent.md)
- [XGameInvite (deprecated)](/reference/system/xgameinvite/xgameinvite_members.md)
- [Receiving invites](/services/xbox-services/multiplayer/invites/how-to/live-invites-receive.md)
- [XGameActivationCallback](/reference/system/xgameactivation/functions/xgameactivationcallback.md)
