Social (Cocos)
Two layers of social in the Cocos wrapper:
- FRVR friends graph — synced to the server, cross‑channel:
syncFriends,getAllFriends,addFriend,removeFriend. - Platform surfaces — native share sheet, invite picker, and update channel:
shareMessage,inviteUsers,sendUpdate,getPlatformFriends. Gated by the current channel.
For real‑time events (friend status changes, game invite sockets), see Social live.
FRVR friends
Section titled “FRVR friends”Requires the player to be authenticated.
Call syncFriends() once per session — it uploads the channel’s friend list so the FRVR backend can match and register them.
Check what the channel supports
Section titled “Check what the channel supports”Different channels expose different subsets — guard your UI before showing buttons:
Common API names you can pass to isSocialAPISupported: shareMessage, inviteUsers, sendUpdate, getPlatformFriends, getContextId, getContextData, getContextPlayers.
Share a message
Section titled “Share a message”Posts to the user’s timeline / story / share sheet, depending on the channel.
| Field | Type | Required | Purpose |
|---|---|---|---|
image | string | yes | Image data URL or hosted URL (BASE64 / JPEG / PNG). |
text | string | yes | Body / description text. |
headline | string | no | Short headline above the body, where supported. |
cta | string | no | Call‑to‑action button label. |
entryPointData | object | no | Payload delivered to the recipient via entry point when they open the share. |
Invite friends
Section titled “Invite friends”Opens the channel’s friend picker so the player can invite specific contacts directly into the game.
| Field | Type | Required | Purpose |
|---|---|---|---|
image | string | yes | Image data URL or hosted URL (BASE64 / JPEG / PNG). |
text | string | yes | Message shown alongside the image. |
headline | string | no | Short headline above the body, where supported. |
cta | string | no | Call‑to‑action button label. |
entryPointData | object | no | Payload available to the recipient through entry point on join. |
canInvite() returns false on channels where invites are unavailable — gate your UI on it.
Send a platform update
Section titled “Send a platform update”Yields control to the platform so it can deliver a templated update (Facebook context update, Snapchat sticker, Discord activity, …). Templates live in the SDK’s default templates config — drop the channel‑specific config into your game folder to use them.
| Field | Type | Purpose |
|---|---|---|
template | string | Predefined template name (e.g. 'JOIN_PLAYER'). |
image | string | Image data URL or hosted URL (BASE64 / JPEG / PNG). |
bitmojiVariant | string | Snapchat bitmoji pose — 'HAPPY', 'WINK', 'HEARTEYES', etc. |
entryPointData | object | Payload delivered via entry point when the recipient opens the update. |
override | object | Channel‑specific raw payloads (snapchat, facebookInstant, facebookRooms, discord) that replace the template fields. |
Platform friends
Section titled “Platform friends”Read the channel’s native friend list (e.g. the player’s Facebook gaming friends):
Use this for invite UIs that mimic the host platform’s look, or to pre‑populate a “friend picker” of your own. For the cross‑channel FRVR graph, use getAllFriends() instead.
Host context
Section titled “Host context”Where the user currently is on the host (FB context, Snap chat, Discord activity):
getContextPlayers() returns the same Friend[] shape as getPlatformFriends(), scoped to whoever is currently in the chat / room / party with the player.
Related
Section titled “Related”- FRVR friend graph semantics, server sync: Web SDK social.
- Real‑time presence and game invites: Social live.