Messages

You can use the methods from the TapCoreMessageManager class to manage chat messages.

Method NameDescription

Send a new text message to the selected chat room.

Send a new image message to the selected chat room.

Send a new video message to the selected chat room.

Send a new file message to the selected chat room.

Send a new message with location to the selected chat room.

Send a new voice message to the selected chat room.

Send a new link message to the selected chat room.

Forward an existing message to the selected chat room.

Construct a customized TapTalk.io message model.

Send a new custom message to the room defined in the message model.

Edit the contents of the selected message

Call this method to search messages from the device's local storage with a keyword

Set message as starred or remove star from message for the active user.

Retrieve list of messages marked as starred in a chat room.

Set message as pinned or remove pin from message for all room participants.

Retrieve list of pinned messages in a chat room.

Retrieve image, video, file, and link messages from a chat room.

Start a file download from the selected file, image, or video message.

Mark message as read by the active user.

Mark message as delivered by the active user.

Retrieve messages that are older than the provided timestamp from the server to the selected chat room.

Retrieve newer messages from the server to the selected chat room

Retrieve existing media messages from a chat room

DeleteMessage

tapCoreMessageManager.markMessageAsDeleted(
    ROOM_ID, 
    MESSAGE_IDs, 
    FOR_EVERYONE
);

ROOM_ID: (String) room ID value MESSAGE_IDs: (Arrray) array of messageID FOR_EVERYONE: (boolean) message model of message you want to quoted

SendTextMessage

tapCoreMessageManager.sendTextMessage(
    MESSAGE_BODY, 
    ROOM, 
    (message) => {
        // do action here
    },
    QUOTED_MESSAGE, 
    FORWARD_MESSAGE, 
    FORWARD_ONLY, 
    QUOTE_TITLE
);

MESSAGE_BODY: (String) message body for message model ROOM: (Object) room model for message model QUOTED_MESSAGE: (Object) message model of message you want to quoted FORWARD_MESSAGE: (Object) message model of message you want to forward FORWARD_ONLY: (boolean) set to true when you only need to forward an existing message without sending a new message QUOTE_TITLE: (String) custom text for message.quote.title

SendImageMessage

tapCoreMessageManager.sendImageMessage(
    FILE, 
    CAPTION, 
    ROOM, 
    {
      onStart: (message) => {
          // Message model was generated
      },
      onProgress: (localID, percentage, bytes) => {
          // File upload progress
      },
      onSuccess: (message) => {
          // do action here
      },
      onError: (errorCode, errorMessage) => {
          // do action here
      }
    }, 
    QUOTED_MESSAGE, 
    FORWARD_MESSAGE,
    FORWARD_ONLY,
    QUOTE_TITLE
);

FILE: (Object) the image file to be uploaded CAPTION: (String) the image's caption to be displayed in message bubble ROOM: (Object) room model for message model QUOTED_MESSAGE: (Object) message model of message you want to quoted FORWARD_MESSAGE: (Object) message model of message you want to forward FORWARD_ONLY: (boolean) set to true when you only need to forward an existing message without sending a new message QUOTE_TITLE: (String) custom text for message.quote.title

SendVideoMessage

tapCoreMessageManager.sendVideoMessage(
    FILE, 
    CAPTION, 
    ROOM, 
    {
      onStart: (message) => {
          // Message model was generated
      },
      onProgress: (localID, percentage, bytes) => {
          // File upload progress
      },
      onSuccess: (message) => {
          // do action here
      },
      onError: (errorCode, errorMessage) => {
          // do action here
      }
    }, 
    QUOTED_MESSAGE, 
    FORWARD_MESSAGE,
    FORWARD_ONLY,
    QUOTE_TITLE
);

FILE: (Object) the video file to be uploaded CAPTION: (String) the image's caption to be displayed in message bubble ROOM: (Object) room model for message model QUOTED_MESSAGE: (Object) message model of message you want to quoted FORWARD_MESSAGE: (Object) message model of message you want to forward FORWARD_ONLY: (boolean) set to true when you only need to forward an existing message without sending a new message QUOTE_TITLE: (String) custom text for message.quote.title

SendFileMessage

tapCoreMessageManager.sendFileMessage(
    FILE, 
    ROOM, 
    {
      onStart: (message) => {
          // Message model was generated
      },
      onProgress: (localID, percentage, bytes) => {
          // File upload progress
      },
      onSuccess: (message) => {
          // do action here
      },
      onError: (errorCode, errorMessage) => {
          // do action here
      }
    }, 
    QUOTED_MESSAGE, 
    FORWARD_MESSAGE,
    FORWARD_ONLY,
    QUOTE_TITLE
);

FILE: (Object) the file to be uploaded CAPTION: (String) the image's caption to be displayed in message bubble ROOM: (Object) room model for message model QUOTED_MESSAGE: (Object) message model of message you want to quoted FORWARD_MESSAGE: (Object) message model of message you want to forward FORWARD_ONLY: (boolean) set to true when you only need to forward an existing message without sending a new message QUOTE_TITLE: (String) custom text for message.quote.title

SendLocationMessage

tapCoreMessageManager.sendLocationMessage(
    LATITUDE,
    LONGITUDE,
    ADDRESS, 
    ROOM, 
    (message) => {
        // do action here
    },
    QUOTED_MESSAGE, 
    FORWARD_MESSAGE, 
    FORWARD_ONLY, 
    QUOTE_TITLE
);

LATITUDE: (Number) latitude of the shared location LONGITUDE: (Number) longitude of the shared location ADDRESS: (String) text data containing the location address ROOM: (Object) room model for message model QUOTED_MESSAGE: (Object) message model of message you want to quoted FORWARD_MESSAGE: (Object) message model of message you want to forward FORWARD_ONLY: (boolean) set to true when you only need to forward an existing message without sending a new message QUOTE_TITLE: (String) custom text for message.quote.title

SendVoiceMessage

tapCoreMessageManager.sendVoiceMessage(
    FILE, 
    DURATION, 
    ROOM, 
    {
      onStart: (message) => {
          // Message model was generated
      },
      onProgress: (localID, percentage, bytes) => {
          // File upload progress
      },
      onSuccess: (message) => {
          // do action here
      },
      onError: (errorCode, errorMessage) => {
          // do action here
      }
    }, 
    QUOTED_MESSAGE, 
    FORWARD_MESSAGE,
    FORWARD_ONLY,
    QUOTE_TITLE
);

FILE: (Object) the voice note file to be uploaded DURATION: (Number) the playback duration of the voice note file ROOM: (Object) room model for message model QUOTED_MESSAGE: (Object) message model of message you want to quoted FORWARD_MESSAGE: (Object) message model of message you want to forward FORWARD_ONLY: (boolean) set to true when you only need to forward an existing message without sending a new message QUOTE_TITLE: (String) custom text for message.quote.title

SendLinkMessage

tapCoreMessageManager.sendLinkMessage(
    MESSAGE_BODY, 
    ROOM, 
    (message) => {
        // do action here
    },
    URLS,
    TITLE,
    DESCRIPTION,
    IMAGE,
    SITE_NAME,
    TYPE,
    QUOTED_MESSAGE, 
    FORWARD_MESSAGE, 
    FORWARD_ONLY, 
    QUOTE_TITLE
);

MESSAGE_BODY: (String) message body for message model ROOM: (Object) room model for message model URLS: (NSArray<String>) list of URLs contained in the message TITLE: (String) og:title metadata of the specified URL DESCRIPTION: (String) og:description metadata of the specified URL IMAGE: (String) og:image metadata of the specified URL SITE_NAME: (String) og:site_name metadata of the specified URL TYPE: (String) og:type metadata of the specified URL QUOTED_MESSAGE: (Object) message model of message you want to quoted FORWARD_MESSAGE: (Object) message model of message you want to forward FORWARD_ONLY: (boolean) set to true when you only need to forward an existing message without sending a new message QUOTE_TITLE: (String) custom text for message.quote.title

Send Forwarded Messages

To send a forwarded message to a chat room, use the sendForwardMessage() method from the TapCoreMessageManager class.

tapCoreMessageManager.sendForwardMessage(ROOM_MODEL, (message) => {
   // do action here
}, FORWARD_MESSAGES)

Parameters ROOM_MODEL: (TAPRoomModel) the destination room where the message will be sent CALLBACK: (Method) callback method FORWARD_MESSAGES: (Array) array of forward messages

Send Forwarded Messages to Multiple Rooms

To send multiple forwarded message to multiple chat room, use the sendForwardMessagesOnMultipleRooms() method from the TapCoreMessageManager class.

let DATA = [{
   room: {
      ...ROOM_MODEL
   },
   messages: [
      {
         ...MESSAGE_MODEL
      }
   ]
}]

tapCoreMessageManager.sendForwardMessagesOnMultipleRooms(DATA, (message) => {
   // do action here
})

Parameters DATA: (Array) array of room and forward messages CALLBACK: (Method) callback method

ConstructTapTalkMessageModel

tapCoreMessageManager.constructTapTalkMessageModel(MESSAGE_BODY, ROOM, MESSAGE_TYPE, MESSAGE_DATA, LOCAL_ID = null, forwardMessage = false);

MESSAGE_BODY: (String) message body for message model ROOM: (Object) room model for message model MESSAGE_TYPE: (Number) message type for message model MESSAGE_DATA: (Object) data object for message model LOCAL_ID: (String) custom value for preference local id default is null FORWARD_MESSAGE: (Object) message model of message you want to forward

ConstructTapTalkMessageModelWithQuote

tapCoreMessageManager.constructTapTalkMessageModelWithQuote(MESSAGE_BODY, ROOM, MESSAGE_TYPE, MESSAGE_DATA, QUOTED_MESSAGE = false, LOCAL_ID = null, QUOTE_TITLE= false, QUOTE_CONTENT = false, QUOTED_IMAGE_URL = false);

MESSAGE_BODY: (String) message body for message model ROOM: (Object) room model for message model MESSAGE_TYPE: (Number) message type for message model MESSAGE_DATA: (Object) data object for message model LOCAL_ID: (String) custom value for preference local id default is null QUOTED_MESSAGE: (Object) message model of message you want to quoted QUOTE_TITLE: (String) title for your quoted message default is false QUOTE_CONTENT: (String) content for your quoted message default is false QUOTED_IMAGE_URL: (String) image url for your quoted message default is false

SendCustomMessage

tapCoreMessageManager.sendCustomMessage(MESSAGE_MODEL, (message) => {
    // do action here
});

MESSAGE_MODEL: (Object) message model for your message

Edit Message

To edit amessage in a chat room, use the sendEmitWithEditedMessage() method from the TapCoreMessageManager class.

tapCoreMessageManager.sendEmitWithEditedMessage(MESSAGE, NEW_MESSAGE, (message) => {
   // do action here
})

Parameters MESSAGE: (Object) message model of the edit message NEW_MESSAGE: (String) new message value CALLBACK: (Method) callback method

SearchLocalRoomMessageWithKeyword

Call this method to search messages from the chat room with a keyword.

tapCoreMessageManager.searchLocalRoomMessageWithKeyword(KEYWORD, ROOM_ID, {
 onSuccess: (response) => {
   // do action here
 }, 
 onError: (message) => {
   // do action here
 }
});

KEYWORD: (String) message keyword ROOM_ID: (number) room id CALLBACK: (Object) callback method

SearchLocalMessageWithKeyword

Call this method to search messages from all chat room with a keyword.

tapCoreMessageManager.searchLocalMessageWithKeyword(KEYWORD, {
 onSuccess: (response) => {
   // do action here
 }, 
 onError: (message) => {
   // do action here
 }
});

KEYWORD: (String) message keyword CALLBACK: (Object) callback method

StarMessage

You may use these methods to mark a message or multiple messages as starred.

tapCoreMessageManager.starMessage(ROOM_ID, MESSAGE_IDs, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
);

ROOM_ID: (Number) room id MESSAGE_IDs: (Array) array of message id CALLBACK: (Object) object of callback methods

UnstarMessage

You may use these methods to remove messages from the starred list.

tapCoreMessageManager.unstarMessage(ROOM_ID, MESSAGE_IDs, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
);

ROOM_ID: (Number) room id MESSAGE_IDs: (Array) array of message id CALLBACK: (Object) object of callback methods

GetStarredMessageIds

You can use the method below get a list of message IDs marked as starred by the user.

tapCoreMessageManager.getStarredMessageIds(roomID, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});

ROOM_ID: (Number) room id CALLBACK: (Object) object of callback methods

FetchStarredMessages

You can use the method below get a list of message IDs marked as starred by the user.

tapCoreMessageManager.fetchStarredMessages(ROOM_ID, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});

ROOM_ID: (Number) room id CALLBACK: (Object) object of callback methods

FetchSharedContentMessages

You may use this method to fetch shared content messages from the server. This currently includes image, video, file, and link messages.

tapCoreMessageManager.fetchSharedContentMessages(ROOM_ID MAX_CREATED, MIN_CREATED, SORT, {
    onSuccess: (mediasResponse, filesResponse, linksResponse) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});

ROOM_ID: (Number) room id CALLBACK: (Object) object of callback methods MAX_CREATED: (Number) the highest created time of the shared content to be retrieved MIN_CREATED: (Number) the lowest created time of the shared content to be retrieved SORT: (String) sorting order (fill with "ASC" or "DESC"), default value is "ASC"

FetchPinnedMessages

You can fetch pinned messages list with this method below.

tapCoreChatRoomManager.fetchPinnedMessages(ROOM_ID, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});

ROOM_ID: (Number) room id CALLBACK: (Object) object of callback methods

GetPinnedMessageIds

You can fetch all pinned messages ID list with this method below.

tapCoreChatRoomManager.getPinnedMessageIds(ROOM_ID, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});

ROOM_ID: (Number) room id CALLBACK: (Object) object of callback methods

PinMessage

You can set pin messages with this method below.

tapCoreChatRoomManager.pinMessage(ROOM_ID, MESSAGES, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});

ROOM_ID: (Number) room id MESSAGES: (Array) arrays of message model CALLBACK: (Object) object of callback methods

UnpinMessage

You can set pin messages with this method below.

tapCoreChatRoomManager.unpinMessage(ROOM_ID, MESSAGES_IDs, IS_UNPIN_ALL, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});

ROOM_ID: (Number) room id MESSAGES_IDs: (Array) arrays of message ID IS_UNPIN_ALL: (Boolean) set true if unpin all message CALLBACK: (Object) object of callback methods

Download Message File

To start a file download from a File, Image, or Video message, you can use the downloadMessageFile() method.

tapCoreChatRoomManager.downloadMessageFile(messageModel, {
      onSuccess : (response) => {
         // do action here
      },
      onError: (errorCode, errorMessage) => {
         // do action here     
      }
})

Parameters

MESSAGE: (TAPMessageModel) pending message with ongoing file upload

Mark Message as Read

To manually mark a message as read, call the markMessageAsRead() method.

tapCoreMessageManager.markMessageAsRead(ARRAY_OF_MESSAGE_ID)

Parameters

ARRAY_OF_MESSAGE_ID: (TAPMessageModel) existing message to be marked as read

Mark Message as Delivered

To manually mark a message as delivered, call the markMessageAsDelivered() method.

tapCoreMessageManager.markMessageAsDelivered(ARRAY_OF_MESSAGE_ID)

Parameters

ARRAY_OF_MESSAGE_ID: (TAPMessageModel) existing message to be marked as read

Get Older Messages from Chat Room

To retrieve older messages in a chat room from the server, use the getOlderMessagesBeforeTimestamp() method.

tapCoreMessageManager.getOlderMessagesBeforeTimestamp(ROOM_ID, NUMBER_OF_ITEMS, {
   onSuccess: (messages, hasMore) => {
          // do action here
    },
    onError: (errorCode, errorMessage) => {
          // do action here
    }
})

Get Newer Messages from Chat Room

To retrieve newer messages in a chat room from the server, use the getNewerMessagesAfterTimestamp() method.

tapCoreMessageManager.getNewerMessagesAfterTimestamp(ROOM_ID, {
   onSuccess: (messages) => {
          // do action here
    },
    onError: (errorCode, errorMessage) => {
          // do action here
    }
})

Get Total Read Count

Get total read count of a message

tapCoreChatRoomManager.getTotalReadCount(MESSAGE_ID, {
      onSuccess : (response) => {
         // do action here
      },
      onError: (errorCode, errorMessage) => {
         // do action here     
      }
})

Parameters

MESSAGE_ID: (Number) message id CALLBACK: (Object) object of callback method

Fetch Message Info

Fetch message info (read by and delivere to).

tapCoreChatRoomManager.fetchMessageInfo(MESSAGE_ID, {
      onSuccess : (response) => {
         // do action here
      },
      onError: (errorCode, errorMessage) => {
         // do action here     
      }
})

Parameters

MESSAGE_ID: (Number) message id CALLBACK: (Object) object of callback method

Last updated