Presence
Online Presence allows an app's users to know which of their friends are currently online, what they are doing, and whether they are available to interact.
The Presence Service enables the tracking of this live user activity. In order for any of these calls to be functional, the Presence feature must be enabled for your app. brainCloud RTT is also required.
See Design | Messaging | Presence in the portal.
API Summary
Basic Presence
The user's online status is automatically registered when they connect to brainCloud RTT. From there, the following API calls can be used to update the user's presence state and activity.
- UpdateActivity - update the user's rich activity data
- SetVisibility - hide the user's online state
Getting Presence Status
The following API calls are used to directly request the presence status of other users:
- GetPresenceOfFriends - get presence of friends
- GetPresenceOfGroup - get presence of specified group
- GetPresenceOfUsers - get presence of specified set of users
Real-time Presence
Use these API calls to configure real-time presence updates:
- RegisterListenersForFriends - register listeners with all friends
- RegisterListenersForGroup - register listeners with the specified group
- RegisterListenersForProfiles - register listeners with the specified list of users (profiles)
- StopListening - deregisters are listeners
- ForcePush - force an update to all listeners
System calls
The system API calls can be used to register presence for users who are not currently connected via RTT. Useful for Internet-of-Things use cases. Callable by cloud-code only.
- SysInitializePresence - initialize presence for the specified user
- SysExtendPxExpiry - extend the presence state
- SysTerminatePresence - terminate presence for the specified user
📄️ ForcePush
Force an RTT presence update to all listeners of the caller. Note that Real-time Tech(RTT) updates must be enabled in order for this API call to work (see Messaging > Presence in the portal).
📄️ GetPresenceOfFriends
Gets the presence data for the given platform. Can be one of "all", "", or "facebook". Will not include offline profiles unless includeOffline is set to true.
📄️ GetPresenceOfGroup
Gets the presence data for the given groupId. Will not include offline profiles unless includeOffline is set to true.
📄️ GetPresenceOfUsers
Gets the presence data for the given profileIds. Will not include offline profiles unless includeOffline is set to true.
📄️ RegisterListenersForFriends
Registers the caller for RTT presence updates from friends on the given platform. Can be one of "all", "", or "facebook". If bidirectional is set to true, then also registers the targeted users for presence updates from the caller.
📄️ RegisterListenersForGroup
Registers the caller for RTT presence updates from the members of the given groupId. Caller must be a member of said group. If bidirectional is set to true, then also registers the targeted users for presence updates from the caller.
📄️ RegisterListenersForProfiles
Registers the caller for RTT presence updates for the given profileIds. If bidirectional is set to true, then also registers the targeted users for presence updates from the caller.
📄️ SetVisibility
Update the presence data visible field for the caller. An RTT event will be sent to any registered listeners of the caller with their updated presence info.
📄️ StopListening
Stops the caller from receiving RTT presence updates. Does not affect the broadcasting of their presence updates to other listeners. Note that Real-time Tech(RTT) updates must be enabled in order for this API call to work (see Messaging > Presence in the portal).
📄️ SysExtendPxExpiry
This method is available in Cloud Code scripts only.
📄️ SysInitializePresence
This method is available in Cloud Code scripts only.
📄️ SysTerminatePresence
This method is available in Cloud Code scripts only.
📄️ UpdateActivity
Update the presence data activity field for the caller. Note that Support rich activity must be enabled in order for this API call to work (see Messaging > Presence in the portal). An RTT event will be sent to any registered listeners of the caller with their updated presence info.