Skip to main content
This article provides example code that uses the XBOX services API (XSAPI) to handle title Presence changes. To receive title Presence notifications, register a handler first, and then track the users and titles that you’re interested in. When you no longer need notifications, stop tracking the users and titles and remove the handler. In the examples, xboxLiveContext is an XblContextHandle for the signed-in local user, state is a title-defined object that stores the handler token, and LogToFile is a title-defined logging function. Replace 123 with the XBOX user ID (XUID) of a user whose Presence you want to track, and replace otherTitleId with the title ID of another title that you want to track.
XblPresenceSubscribeToTitlePresenceChange and XblPresenceUnsubscribeFromTitlePresenceChange are deprecated. Don’t use them in new code. XSAPI manages the Real-Time Activity (RTA) subscriptions for you when you track users with XblPresenceTrackUsers and titles with XblPresenceTrackAdditionalTitles.

Adding a title Presence change handler

Register the handler before you track users and titles. The function returns 0 if xblContextHandle or handler is null.
For more information, see XblPresenceTitleState.

Tracking users and titles

Title Presence change handlers receive notifications only for the users that you track with XblPresenceTrackUsers and the titles that you track. The current title is tracked by default, so call XblPresenceTrackAdditionalTitles only for other titles. Each call adds to the existing list. Check the result of each call.
Tracking is reference counted. Make a matching stop call for each successful tracking call. The list of tracked users applies to both device and title Presence notifications.

Stopping tracking users and titles

When you no longer need title Presence updates, stop tracking the titles and users that you tracked, and check each result. XblPresenceStopTrackingAdditionalTitles doesn’t stop tracking the current title.

Removing a title Presence change handler

Remove the handler by passing the token that XblPresenceAddTitlePresenceChangedHandler returned. Clear the stored token only after the call succeeds.

See also

XblPresenceAddTitlePresenceChangedHandler XblPresenceRemoveTitlePresenceChangedHandler XblPresenceTrackUsers XblPresenceTrackAdditionalTitles XblPresenceStopTrackingAdditionalTitles Handling a device Presence change
Last modified on October 29, 2026