onymos-logo

onymosChat.getList

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);
}
);
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.

onymosChat.listenForList

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
);
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.

options
listenForChanges

Boolean

When set to true, the successCallback will be called for every new (last) message added to a particular Chat.
Example: { listenForChanges: true }

onymosChat.stopListenForList

To stop listening for a list of Chats that the user is participating in.

OnymosChat.stopListenForList(userId);
Note: This is a synchronous call.
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.

onymosChat.getMessages

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);
}
);
senderObject

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’
}
arrayOfRecipientObjects

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’
}

onymosChat.listenForMessages

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
);
senderObject

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’
}
arrayOfRecipientObjects

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’
}

options
numberOfRecords

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.

onymosChat.stopListenForMessages

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);
senderObject

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’
}
arrayOfRecipientObjects

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’
}

onymosChat.loadMessagesPreviousSet

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
);
senderObject

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’
}
arrayOfRecipientObjects

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’
}
options
numberOfRecords

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.

onymosChat.sendMessage

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
);
senderObject

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’
}
arrayOfRecipientObjects

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’
}
messageContent

String

A text string with the message content.

options
chatCustomObject

JSON Object

Any custom JSON data object to be stored with this Chat message.

Think differently about app development

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.

Get your free white paper

Overlay