Skip Navigation

METHOD_PC_GetChatHistory

This method sends a request to 
BEMS
 to return the chat history for a group discussion. 
Parameter
Type
Required
Description
roomsId
String 
This parameter specifies a list of group discussion IDs that a user can view the chat history for. 
resultLimit
Number
This parameter specifies the maximum number of messages that a user can see in the group discussion. By default, the maximum number of group discussion messages a user can see is 20. Users can view messages in batches of 20 messages or less.
searchString
String
This parameter specifies the string to search for in the group discussion chat history.
authors
String Array
This parameter specifies a list of users that sent messages in the group discussion that users can search for.
startDate
Number
This parameter specifies the start date of the group discussion chat history. The startDate is specified in epoch time format.
endDate
Number
This parameter specifies the end date of the group discussion chat history. The endDate is specified in epoch time format. 
afterMessageId
String
This parameter specifies the message ID after which to retrieve messages sent to the group discussion. If this parameter is specified, the startDate is disregarded.
chronological
Boolean
This parameter lists the group discussion messages in chronological order. By default, the order is false and the messages appear in reverse chronological order.

Notification

The following table describes the parameters that 
BEMS
 returns and the notifications that are sent to the 
BlackBerry Connect
 app when users request the chat history.
Parameter
Type
Description
messages
Message Array
This parameter lists the messages in the group discussion. Each message includes the following information:
Parameter
Type
Description
message
String
This parameter specifies the message content.
messageId
String
This parameter specifies the message ID of the message sent.
authorId
String
This parameter specifies the ID of the contact that sent the message.
authorDisplayName
String
This parameter displays the sender's name. 
isAlert
Boolean
This parameter specifies that the message is flagged as an alert message. By default, this parameter is set to False.
timeStamp
Number
This parameter specifies the time stamp date of the message sent to the group discussion. The timeStamp is specified in epoch time format.
fileLinkCount
Number
This parameter specifies the number of file links in the message.
moreResults
Boolean
This parameter specifies whether more results are available.
  • If true, more results are available, but were not returned because of the set resultLimit parameter.
  • If false, then all the results are returned.

Code example

The following example sends a request to 
BEMS
 to return the chat history of a group discussion room. In this example, the request retrieves messages in batches of 20 messages as specified by the resultLimit.
{ "method":"pc.GetChatHistory", "params": { "roomId":"ma-chan://gems.example.com/25ac15e7-9bff-4e78-9261-6e08aa43231e", "resultLimit":20 }, "id":"c5", "jsonrpc":"2.0" }
If the request is successful, 
BEMS
 sends the following response to the 
BlackBerry Connect
 app and processes the request.
{ "id":"c5", "error":null, "result": { "data": { "method":"pc.GetChatHistory", "state":"PROCESSING" } }, "jsonrpc":"2.0" }
If there are no errors, 
BEMS
 displays the message history and includes information about the user that posted the messages to the discussion group, when the message was sent, any links the message might include, and if more results are available.   
{ "id":"c5", "sequence":1018819000000039, "result": { "data": { "method":"pc.GetChatHistory", "messages": [ { "message":"Release build ready", "messageId":"125988FKKFJFHI2345", "authorId":"sip:user1@example.com", "authorDisplayName":"User 1", "isAlert":False, "fileLinkCount":0, "timeStamp":1487015504 }, { "message":"Is the release build done?", "messageId":"125988FKKFJFHI21344", "authorId":"sip:user2@example.com", "authorDisplayName":"User 2", "isAlert":False, "fileLinkCount":0, "timeStamp": 14870132441 } ], "moreResults":false "method":"pc.GetChatHistory", "state":"COMPLETE" } }, "jsonrpc":"2.0" }