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.
XblPresenceSubscribeToDevicePresenceChange and XblPresenceUnsubscribeFromDevicePresenceChange 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 stop tracking them with XblPresenceStopTrackingUsers.Adding a device Presence change handler
Register a handler that XSAPI calls when the device Presence of a tracked user changes. The function returns 0 if xblContextHandle or handler is null.Tracking users for device Presence changes
Device Presence change handlers receive notifications only for the users that you track withXblPresenceTrackUsers. Each call adds users to the existing list of tracked users. You can update the list of tracked users independently from the handlers.
XblPresenceStopTrackingUsers call for each successful XblPresenceTrackUsers call. The list of tracked users applies to both device and title Presence notifications.
Stopping tracking users
When you no longer need Presence updates for a user, stop tracking the user.Removing a device Presence change handler
Remove the handler by passing the token thatXblPresenceAddDevicePresenceChangedHandler returned. Clear the stored token only after the call succeeds.
