Chat Room and Messages - TapCore
If you are using core implementation method, you can use the methods below to manage chat room and messages.
Note: Please add #import <TapTalk/TAPCoreChatRoomManager.h> or
#import <TapTalk/TAPCoreMessageManager.h> before using these methods.
TapTalk Group Chat Method
Description
Returns the room model of the currently active chat room.
Create new personal chat room with recipient user, or obtain chat room data if it already exists.
Create new personal chat room with recipient user ID, or obtain chat room data if it already exists
Obtain locally saved chat room details with a roomID.
Create a new group chat room with selected group name.
Create a new group chat room with selected group name and group picture.
Get group room data from selected group room ID.
Update existing group chat room data.
Update group picture with current selected image.
Delete group chat room from the device's local storage.
Delete group chat room and clear all chat data and participants.
Leave from selected group chat.
Add selected member(s) to current group chat room.
Remove selected member(s) from current group chat room.
Promote selected member(s) as admin(s) to the current group chat room.
Demote selected admin(s) to member(s) to the current group chat room.
Obtain Saved Messages chat room data
Notify that the active user has started typing in the selected room.
Notify that the active user has stopped typing in the selected room.
Send a new text message to the selected chat room.
Send a new message with location 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 voice message to the selected chat room.
Send a new link message to the selected chat room.
Forward existing messages 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
Delete the selected message from the server.
Delete the selected message from local storage.
Cancel image, video, or file upload on the selected pending message.
Start a file download from the selected file, image, or video message.
Cancel image, video, or file download on the selected message.
Mark message as delivered by the active user.
Mark message as read by the active user.
Mark all unread messages in a chat room as read.
Retrieve messages from chat room that are already stored in the device's local storage.
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 all available messages from the selected chat room.
Retrieve unread messages from the device's local storage.
Retrieve media messages from the device's local storage.
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.
Clear all existing messages in a selected chat room for the active user.
Schedule a message to be delivered at a specified time.
Retrieve list of created scheduled messages in a chat room.
Send a previously created scheduled message immediately to the recipient.
Change the deliver time of a previously created scheduled message.
Update the contents of a scheduled message that has not been delivered.
Delete a scheduled message that has not been delivered.
Retrieve info about a message's recipients that has read or received the message.
Retrieve a message's total read count from a non-personal room.
Get Active Chat Room
Returns the room model (TAPRoomModel) of the currently active chat room.
Get Local Chat Room Data
Obtain locally saved chat room details with a roomID. Returns the saved room model or nil if it does not exist.
Create Group Chat Room
Create a new group chat room with selected group name.
Get Personal Chat Room with Recipient User
Create new personal chat room with recipient user, or obtain chat room data if it already exists.
Get Personal Chat Room with Recipient User ID
Create new personal chat room with recipient user ID, or obtain chat room data if it already exists.
Create Group Chat Room
Create a new group chat room with selected group name and group picture.
Get Group Chat Room
Get group room data from selected group room ID.
Update Group Chat Room Details
Create a new Update existing group chat room data.
Update Group Image
Update group picture with current selected image.
Delete Local Group Chat Room
Delete group chat room from the device's local storage and clear all chat data and participants. Locally deleted room data will still be accessible from the server if the user remains a participant in the room.
Delete Group Chat Room
Delete group chat room and clear all chat data and participants.
Leave Group Chat
Leave from selected group chat.
Add Members to Group Chat
Add selected member(s) to current group chat room.
Remove Members from Group Chat
Remove selected member(s) from current group chat room.
Promote Group Admin
Promote selected member(s) as admin(s) to the current group chat room.
Demote Group Admin
Demote selected admin(s) to member(s) to the current group chat room.
Get Saved Messages Chat Room
Obtain Saved Messages chat room data.
Send Start Typing
Notify that the active user has started typing in the selected room.
Send Stop Typing
Notify that the active user has stopped typing in the selected room.
Send Text Message
To send a text message to a chat room, use the sendTextMessage:room:start:success:failure: method from the TapCoreMessageManager class.
Use the sendTextMessage:quotedMessage:room:start:success:failure: method to send a text message with quote.
Send Location Message
You can send a location embedded in a chat message using sendLocationMessageWithLatitude:longitude:address:room:start:success:failure:. This method takes latitude, longitude, and address text as parameters.
Use the sendLocationMessageWithLatitude:longitude:quotedMessage:address:room:start:success:failure: method to send a location message with quote.
Send Image Message
To send an image to a chat room, you can use sendImageMessage: or sendImageMessageWithAsset: method by providing either UIImage, PHAsset , IMAGE_ASSET_URL, or IMAGE_URL as parameter.
Use the sendImageMessage: or sendImageMessageWithAsset: or sendImageMessageWithRemoteUrl: method with extra parameter to send an image message with quote.
Send Video Message
To send a video to a chat room, you can use sendVideoMessageWithAsset: method by providing the VIDEO_ASSET, VIDEO_ASSET_URL, or a remote VIDEO_URL as parameter.
Use the send video method with extra parameter to send a video message with quote.
Send File Message
You can also send a file to a chat room using sendFileMessageWithFileURI: or sendFileMessageWithRemoteUrl:.
Use the send file method with extra parameter to send a file message with quote.
Send Voice Message
You can also send a voice note to a chat room using the sendVoiceMessageWithFileURI: method with a provided FILE_URI (NSURL).
Use the sendVoiceMessageWithFileURI: method with extra parameter to send a voice message with quote.
Send Link Message
You can send a link message, which is usually composed of a text message with URL on the body, using the sendLinkMessage: method.
Use the sendLinkMessage: method with extra parameters to send a link message with quote.
Forward Message
To forward existing messages to chat room, call the sendForwardedMessage: method. You may also use sendForwardedMessageWithMessageArray: to forward multiple messages at once, or sendForwardedMessage:toMultipleRooms: or sendForwardedMessageWithMessageArray:toMultipleRooms: to forward messages to multiple rooms at once.
Construct TapTalk.io Message Model
You can construct your own customized message model to be used in chat as shown below.
To construct a custom message with quote, use the constructTapTalkMessageModelWithRoom:quotedMessage: method.
Send a Custom Message
To send a custom message that you just created above, call the sendCustomMessageWithMessageModel: method with the custom message as a parameter.
Edit Message
To update the contents of a message, you may use the editMessage: method from TapCoreMessageManager class. Editing is currently available for text message and image or video message caption.
Delete Message
To delete a message permanently from the server, call deleteMessage: from TapCoreMessageManager class. When the message is successfully deleted, TapCoreMessageManagerDelegate will invoke tapTalkDidDeleteMessage: delegate.
Delete Message from Local Cache
To delete a message from local cache, call deleteLocalMessageWithLocalID: from TapCoreMessageManager class.
Cancel Message File Upload
Messages such as Image, Video, and File messages requires a file upload completion before the message is sent. To cancel an ongoing file upload of a message, call the cancelMessageFileUpload: method.
Download Message File
To start a file download from a File, Image, or Video message, you can use these methods below based on what type of message you wish to download.
Cancel Message File Download
You can cancel download message with type such as Image, Video, and File by calling the cancelMessageFileDownload: method.
Mark Message as Delivered
To manually mark a message as delivered, call the markMessageAsDelivered: method.
Mark Message as Read
To manually mark a message as read, call the markMessageAsRead: method. You can also mark multiple messages as read at once using markMessagesAsRead:.
Mark All Chat Room Messages as Read
To quickly mark all unread messages in a chat room as read, call markAllMessageInRoomAsRead: method.
Get Local Messages from Chat Room
In a chat room, you can retrieve messages that are already stored in the device's local storage by calling getLocalMessagesWithRoomID: method.
Retrieving local messages is fast and reliable, but may not contain all messages available in the selected chat room. To obtain more messages that are available from the server, you may use getOlderMessagesBeforeTimestamp: and getNewerMessagesAfterTimestamp: methods.
Get Older Messages from Chat Room
To retrieve older messages in a chat room from the server, use the getOlderMessagesBeforeTimestamp: method.
Get Newer Messages from Chat Room
To retrieve newer messages in a chat room from the server, use the getNewerMessagesAfterTimestamp: method.
You can also call getNewerMessagesWithRoomID: without providing MIN_CREATED_TIMESTAMP and LAST_UPDATE_TIMESTAMP, only providing ROOM_ID as the parameter. With this method, MIN_CREATED_TIMESTAMP will automatically be set to the oldest existing message's created time in the room, and LAST_UPDATE_TIMESTAMP will be obtained from local cache.
Get All Messages from Chat Room
You may also retrieve all available messages from a chat room using the getAllMessagesWithRoomID: method.
getAllMessagesWithRoomID: is convenient to obtain all existing chat room messages since the beginning of the room creation, but the process will take longer depending on the number of messages contained in the selected room.
This method will trigger two success blocks sequentially during the process of retrieving messages:
• successLocalMessages: will be triggered first once local messages are retrieved, the process will then continue to retrieve more messages from the server.
• successAllMessages: will be triggered after all messages from the server are successfully retrieved, this callback contains three parameters containing all messages, older messages (that did not exist in local storage), and newer messages that have recently been updated, the latter two parameters might be empty depending on the situation.
Get Unread Messages from Chat Room
You can retrieve unread messages from the device's local storage by calling getUnreadMessagesFromRoom: method.
Get Media Messages from Chat Room
You can also retrieve media messages from the device's local storage, which consists of image, video, and documents, by calling getMediaMessagesFromRoom: method.
Search Local Message
Call this method to search messages from the device's local storage with a keyword. Provided keyword will be used to filter message body in the search result.
Star/Unstar Messages
You may use these methods to mark a message or multiple messages as starred, or remove messages from the starred list. Only the active user can retrieve his/her own starred messages.
Get Starred Messages
You can use the method below get a list of message IDs marked as starred by the user.
A method to obtain the full message model list of the starred messages with pagination is also provided.
Pin/Unpin Message
You may use these methods to pin or unpin a message or multiple messages in a chat room. Every participant in the room can retrieve the chat room's pinned messages.
Get Pinned Messages
You can use the method below get a list of message IDs of pinned messages in a chat room.
A method to obtain the full message model list of the pinned messages with pagination is also provided.
Get Shared Content Messages
You can retrieve media-type messages, consisting of image, video, file, and link messages from a chat room by using getSharedContentMessages method.
Delete All Chat Room Messages
Use the deleteAllChatRoomMessages: method from the TapCoreChatRoomManager class to clear all existing messages in a selected chat room for the active user. The selected messages will only be deleted for the active user, and will not affect the other participants in the selected room.
Create Scheduled Message
You can schedule a constructed message model to be delivered at a specified time to a chat room.
Get Scheduled Messages
You may then retrieve the list of created scheduled messages that have not yet been delivered in a chat room.
Send Scheduled Message Now
You may also send a previously created scheduled message immediately to the recipient.
Edit Scheduled Message Time
To change the deliver time of a previously created scheduled message, use the editScheduledMessageTime: method from TAPCoreMessageManager.
Edit Scheduled Message Content
You may also update the contents of a scheduled message that was previously created before it is delivered to the recipient.
Delete Scheduled Message
To cancel sending a scheduled message that has not been delivered, you can delete it using deleteScheduledMessage method.
Get Message Details
You can retrieve info about a message's recipients that has read or received the message.
Get Message Total Read Count
You can also retrieve a message's total read count from a non-personal room.
Last updated
Was this helpful?