Messaging
Messaging is a new service that enables rich communications between end-users. It is available to all Plus plan subscriptions - and can optionally utilise brainCloud RTT to send messages in real-time.
Key concepts:
- used for directly addressed messages (via profileIds) - as opposed to Chat messages, which are sent to channels
- is not email (though it is modelled similarly)
- messages are sent within brainCloud only
- and only within a single app
- three types of messages - regular, system and bulk
- regular messages - sent by end-users.
- system messages - sent from the system (i.e. the app) - so the from field is
null
- bulk messages - system messages sent to all users (NOT YET SUPPORTED - COMING SOON!)
- sends real-time events to online users when messages are received (if brainCloud RTT is enabled)
Message content format
{
"msgbox": "inbox",
"msgId": "<guidA>",
"mbCr": 1530070436834,
"mbUp": 1530070436834,
"mbVer": 1,
"message": {
"from": {
"id": "<profileIdA>",
"name": "Holly Leung",
"pic": "<optionalPicUrl>"
},
"to": [
"<profIleIdB>"
],
"sentAt": 1530070436834,
"content": {
"subject": "optional",
"text": "This is a test message"
}
}
}
Message fields
Parameter | Description |
---|---|
msgbox | The box (inbox, sent) that the message is stored in |
msgId | The chat message id (used for editing / deleting posted messages) |
mbCr | Created at date+time in millis |
mbUp | Last updated date+time in millis |
mbVer | The version of the message |
from | Information about the originating user |
to | Array of message recipients |
sentAt | Time+date in millis at which the message was sent |
content | The message content. If plaintext, should contain a text field |
API Summary
Retrieving messages
Sending messages
Updating messages
Sys API Calls
These APIs target the shared content portion of a message, and not the per-user messagebox metadata (which controls whether a message has been read, etc.). Can be used on user or system messages.
Available via cleint session cloud code, as well as S2S.
Retrieving messages
Sending messages
Updating messages
📄️ DeleteMessages
Deletes the local copies of messages from the user's mailbox.
📄️ GetMessageBoxes
Returns the list of messageboxes for this user. currently only supports the default "inbox" and "sent" messageboxes.
📄️ GetMessageCounts
Returns the total # of messages, and # of unread messages, per messagbox, for this user. Note that unread for sent messagebox will always be 0.
📄️ GetMessages
Return the content of the specified messages (if found).
📄️ GetMessagesPage
Given a json context object, returns a page of messages for this user. Note also returns an encoded context object that is used in the follow-up GetMessagesPageOffset api call.
📄️ GetMessagesPageOffset
Returns the next/prev set of messages. Takes the encoded-context from GetMessagesPage as a parameter.
📄️ MarkMessagesRead
Marks the specified message(s) as read.
📄️ SendMessage
Sends a message on behalf of the user. The content of the message can be anything - though be convention it should contain a text field for plaintext content.
📄️ SendMessageSimple
Sends a simple string-based message on behalf of the user.
📄️ SysDeleteMessage
This method is available in Cloud Code scripts only.
📄️ SysDeleteMessages
Deletes specified system messages on the server. Note, if a regular message, deletes all references to it.
📄️ SysGetMessages
This method is available in Cloud Code scripts only.
📄️ SysGetMessagesForOwnerPage
Retrieves the page of messages, owned by specified ownerId, from the server based on the encoded context.
📄️ SysGetMessagesForOwnerPageOffset
Retrieves the page of messages, owned by specified ownerId, from the server based on the encoded context and specified page offset.
📄️ SysGetMessagesPage
Calls to SysGetMessagesPage and PageOffset will start throwing a ProcessingException when brainCloud property useShardSafeMessageLookup set to true, using SysGetMessagesForOwnerPage() instead.
📄️ SysGetMessagesPageOffset
Returns the next/prev page of messages.
📄️ SysSendMessage
This method is available in Cloud Code scripts only.
📄️ SysSendMessageSimple
Sends a simple string-based message on behalf of the system (i.e. app) to the specified users.
📄️ SysUpdateMessage
This method is available in Cloud Code scripts only.