A JavaScript array of objects with the recipients’ userId and userName.
Example:
{
userId: ‘hg4hd-pakd3-nsag64-ng45f-ahn7d’,
userName: ‘Mary Jane’
},
{
userId: ‘u78dj-hcbvt-x8hg4-m7fh3-z87d3’,
userName: ‘Sky Lark’
}
To obtain the list of Chats that the user is participating in.
OnymosChat.getList(
userId,
(listOfChatsArray) => {
/* ------
listOfChatsArray = [{
sender: Sender object,
recipients: Array of Recipient objects,
messageContent: Last message content,
messageCreated: Last message creation time,
options: Last message optional data
}];
------ */
},
(error) => {
console.log(error);
}
);
String
User Id of the Logged-in user. If you are using the Onymos Access component with this app, you can pass ‘@AUTHID@’ which will automatically use the logged-in user’s User Id.
To listen for the list of Chats that the user is participating in. The success callback will be called initially for each Chat that the user is already a participant of at the time of this call, and then each time for any new Chat that the user joins in as a participant.
OnymosChat.listenForList(
userId,
(chatSummary) => {
/* ------
chatSummary = {
messageId: Unique Chat Id,
sender: Sender object,
recipients: Array of Recipient objects,
messageContent: Last message content,
messageCreated: Last message creation time,
options: Last message optional data
};
------ */
},
(error) => {
console.log(error);
},
options
);
String
User Id of the Logged-in user. If you are using the Onymos Access component with this app, you can pass ‘@AUTHID@’ which will automatically use the logged-in user’s User Id.
Boolean
When set to true, the successCallback will be called for every new (last) message added to a particular Chat.
Example: { listenForChanges: true }
To stop listening for a list of Chats that the user is participating in.
OnymosChat.stopListenForList(userId);
String
User Id of the Logged-in user. If you are using the Onymos Access component with this app, you can pass ‘@AUTHID@’ which will automatically use the logged-in user’s User Id.
To obtain messages of a particular Chat. This function is usually called in response to a user clicking on a particular chat summary.
OnymosChat.getMessages(
senderObject,
arrayOfRecipientObjects,
(messageObjectsArray) => {
/* ------
messageObjectsArray = [{
sender: Sender object,
recipients: Array of recipient objects,
messageContent: Message content,
messageCreated: Message creation time,
options: Message optional data
}];
------ */
},
(error) => {
console.log(error);
}
);
Object
A JavaScript object with the logged-in user’s userId and userName. If you are using The Onymos Access component with this app, you can pass ‘@AUTHOBJECT@’ which will automatically use the logged-in user’s User object.
Example:
{
userId: ‘sdfg7-asf7u-lojyh-kh5h4-snund’,
userName: ‘John Doe’
}
Object
A JavaScript array of objects with the recipients’ userId and userName.
Example:
{
userId: ‘hg4hd-pakd3-nsag64-ng45f-ahn7d’,
userName: ‘Mary Jane’
},
{
userId: ‘u78dj-hcbvt-x8hg4-m7fh3-z87d3’,
userName: ‘Sky Lark’
}
To listen for the messages of a particular Chat. This function is usually called in response to a user clicking on a particular Chat summary. The success callback will be called initially for each message that is in the particular Chat at the time of this call, and then each time for any new message that is added to this Chat.
OnymosChat.listenForMessages(
senderObject,
arrayOfRecipientObjects,
(messageObject) => {
/* ------
messageObject = {
sender: Sender object,
recipients: Array of recipient objects,
messageContent: Message content,
messageCreated: Message creation time,
options: Message optional data
};
------ */
},
(error) => {
console.log(error);
},
options
);
Object
A JavaScript object with the logged-in user’s userId and userName. If you are using the Onymos Access component with this app, you can pass ‘@AUTHOBJECT@’ which will automatically use the logged-in user’s User object.
Example:
{
userId: ‘sdfg7-asf7u-lojyh-kh5h4-snund’,
userName: ‘John Doe’
}
Object
A JavaScript array of objects with the recipients’ userId and userName.
Example:
{
userId: ‘hg4hd-pakd3-nsag64-ng45f-ahn7d’,
userName: ‘Mary Jane’
},
{
userId: ‘u78dj-hcbvt-x8hg4-m7fh3-z87d3’,
userName: ‘Sky Lark’
}
Integer
Default: 100
The number of messages you want returned in this function, as well as in the loadMessagesPreviousSet function.
Note: The lesser the number of messages requested, the faster the performance is.
To stop listening for the messages of a particular Chat. This function detaches the callback previously associated using the OnymosChat.listenForMessages call.
OnymosChat.stopListenForMessages(senderObject, arrayOfRecipientObjects);
Object
A JavaScript object with the logged-in user’s userId and userName. If you are using the Onymos Access component with this app, you can pass ‘@AUTHOBJECT@’ which will automatically use the logged-in user’s User object.
Example:
{
userId: ‘sdfg7-asf7u-lojyh-kh5h4-snund’,
userName: ‘John Doe’
}
Object
A JavaScript array of objects with the recipients’ userId and userName.
Example:
{
userId: ‘hg4hd-pakd3-nsag64-ng45f-ahn7d’,
userName: ‘Mary Jane’
},
{
userId: ‘u78dj-hcbvt-x8hg4-m7fh3-z87d3’,
userName: ‘Sky Lark’
}
After a successful invocation of listenForMessages function, you can call the loadMessagesPreviousSet function, to obtain the previous set of 100 (default) messages.
This function returns an array of 0 size, if there are no previous messages available to load.
This function is usually called in response to a scroll-up event. When the user scrolls above a certain number of records, this function is called and the next set of messages are added to the display.
OnymosChat.loadMessagesPreviousSet(
senderObject,
arrayOfRecipientObjects,
(previousSetOfMessagesArray) => {
/* ------
previousSetOfMessagesArray = [{
sender: Sender object,
recipients: Array of recipient objects,
messageContent: Message content,
messageCreated: Message creation time,
options: Message optional data
}];
------ */
},
(error) => {
console.log(error);
},
options
);
Object
A JavaScript object with the logged-in user’s userId and userName. If you are using the Onymos Access component with this app, you can pass ‘@AUTHOBJECT@’ which will automatically use the logged-in user’s User object.
Example:
{
userId: ‘sdfg7-asf7u-lojyh-kh5h4-snund’,
userName: ‘John Doe’
}
Object
A JavaScript array of objects with the recipients’ userId and userName.
Example:
{
userId: ‘hg4hd-pakd3-nsag64-ng45f-ahn7d’,
userName: ‘Mary Jane’
},
{
userId: ‘u78dj-hcbvt-x8hg4-m7fh3-z87d3’,
userName: ‘Sky Lark’
}
Integer
Default: 100
The number of messages you want returned in this function, as well as in the loadMessagesPreviousSet function.
Note: The lesser the number of messages requested, the faster the performance is.
To send a message to one or more recipients. This function is usually called in response to pressing Send button on a text-entry form.
OnymosChat.sendMessage(
senderObject,
arrayOfRecipientObjects,
messageContent,
(status) => {
console.log(status);
},
(error) => {
console.log(error);
},
options
);
Object
A JavaScript object with the logged-in user’s userId and userName. If you are using the Onymos Access component with this app, you can pass ‘@AUTHOBJECT@’ which will automatically use the logged-in user’s User object.
Example:
{
userId: ‘sdfg7-asf7u-lojyh-kh5h4-snund’,
userName: ‘John Doe’
}
Object
A JavaScript array of objects with the recipients’ userId and userName.
Example:
{
userId: ‘hg4hd-pakd3-nsag64-ng45f-ahn7d’,
userName: ‘Mary Jane’
},
{
userId: ‘u78dj-hcbvt-x8hg4-m7fh3-z87d3’,
userName: ‘Sky Lark’
}
String
A text string with the message content.
JSON Object
Any custom JSON data object to be stored with this Chat message.
Download our free white paper today to learn how Onymos Features can maximize the value of your developer resources — and shave weeks or months off your development timeline.