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

# XGameInviteEventCallback (deprecated)

> XGameInviteEventCallback (deprecated)

> [!NOTE]
>
> This API is now deprecated. Use [XGameActivationCallback](https://docs.xbox.com/reference/system/xgameactivation/functions/xgameactivationcallback.md) instead.

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](https://docs.xbox.com/reference/system/xgameinvite/functions/xgameinviteregisterforevent.md).

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

The URI for joining the game session.\
\[!NOTE] XSAPI knows how to consume the URI.

### Return value

Type: void

## Remarks

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

To unregister a callback for a game invite event, call [XGameInviteUnregisterForEvent](https://docs.xbox.com/reference/system/xgameinvite/functions/xgameinviteunregisterforevent.md).

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](https://docs.xbox.com/reference/system/xgameinvite/xgameinvite_members.md)

[XGameInviteRegisterForEvent](https://docs.xbox.com/reference/system/xgameinvite/functions/xgameinviteregisterforevent.md)

[XGameInviteUnregisterForEvent](https://docs.xbox.com/reference/system/xgameinvite/functions/xgameinviteunregisterforevent.md)


## Related topics

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