Skip to main content
This topic provides example code for handling a social relationship change. In the examples, xboxLiveContext is the XblContextHandle for the signed-in user, state holds your title’s state, and LogToFile is a logging function that your title defines.

Subscribing to relationship changes

You don’t need to subscribe to relationship changes separately. The XBOX Services API (XSAPI) creates or reuses one social Real-Time Activity (RTA) subscription for the context. Relationship-changed handlers and incoming friend request count handlers share it. XSAPI removes the subscription only after you remove all handlers of both types.
XblSocialSubscribeToSocialRelationshipChange and XblSocialUnsubscribeFromSocialRelationshipChange are deprecated and don’t manage the RTA subscription. Remove calls to them from your code as a pair. If your code already created a subscription handle with XblSocialSubscribeToSocialRelationshipChange, release it by calling XblSocialUnsubscribeFromSocialRelationshipChange.

Adding a relationship-changed handler

Flat C API

Removing a relationship-changed handler

Flat C API

Handling a change in the number of incoming friend requests

Flat C API
When you no longer need notifications, remove the handler. Remove only a handler that was registered successfully.

See also

XblSocialAddSocialRelationshipChangedHandler XblSocialRemoveSocialRelationshipChangedHandler XblSocialAddFriendRequestCountChangedHandler XblSocialRemoveFriendRequestCountChangedHandler
Last modified on October 29, 2026