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.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>

TAPRoomModel *activeRoom = [[TAPCoreChatRoomManager sharedManager] getActiveChatRoom];

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.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>

TAPRoomModel *room = [[TAPCoreChatRoomManager sharedManager] getLocalChatRoomData:roomID];

Create Group Chat Room

Create a new group chat room with selected group name.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>

[[TAPCoreChatRoomManager sharedManager] createGroupChatRoomWithGroupName:GROUP_NAME listOfParticipantUserIDs:PARTICIPANTS_USERID_ARRAY success:^(TAPRoomModel * _Nonnull room) {
    //Success create group chat
} failure:^(NSError * _Nonnull error) {
    //Failed create group chat
}];

Parameters GROUP_NAME: (String) your group name PARTICIPANTS_USERID_ARRAY: (Array) list of participant userIDs

Get Personal Chat Room with Recipient User

Create new personal chat room with recipient user, or obtain chat room data if it already exists.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>

[[TAPCoreChatRoomManager sharedManager] getPersonalChatRoomWithRecipientUser:RECIPIENT_USER success:^(TAPRoomModel * _Nonnull room) {
   //Success get chat room data
}];

Parameters RECIPIENT_USER: (TAPUserModel) recipient user data

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.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>

[[TAPCoreChatRoomManager sharedManager] getPersonalChatRoomWithRecipientUserID:RECIPIENT_USER_ID success:^(TAPRoomModel * _Nonnull room) {
   //Success get chat room data
} failure:^(NSError * _Nonnull error) {
   //Failed get chat room data
}];

Parameters RECIPIENT_USER_ID: (String) user ID of recipient

Create Group Chat Room

Create a new group chat room with selected group name and group picture.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>

[[TAPCoreChatRoomManager sharedManager] createGroupChatRoomWithGroupName:GROUP_NAME profilePicture:PROFILE_PICTURE listOfParticipantUserIDs:PARTICIPANTS_USER_ID_ARRAY success:^(TAPRoomModel * _Nonnull room, BOOL isSuccessUploadGroupPicture) {
  //Success create group chat  
} failure:^(NSError * _Nonnull error) {
    //Failed create group chat
}];

Parameters GROUP_NAME: (String) your group name PARTICIPANTS_USERID_ARRAY: (Array) list of participant userIDs PROFILE_PICTURE: (UIImage) group picture image

Get Group Chat Room

Get group room data from selected group room ID.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>

[[TAPCoreChatRoomManager sharedManager] getGroupChatRoomWithGroupRoomID:GROUP_ROOM_ID success:^(TAPRoomModel * _Nonnull room) {
  //Success get group chat room
} failure:^(NSError * _Nonnull error) {
  //Failed create group chat room
}];

Parameters GROUP_ROOM_ID: (String) room ID of group

Update Group Chat Room Details

Create a new Update existing group chat room data.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>
  
[[TAPCoreChatRoomManager sharedManager] updateGroupChatRoomDetailsWithGroupRoomID:GROUP_ROOM_ID groupName:GROUP_NAME success:^(TAPRoomModel * _Nonnull room) {
    
} failure:^(NSError * _Nonnull error) {
    
}];

Parameters GROUP_ROOM_ID: (String) room ID of group GROUP_NAME: (String) name of group

Update Group Image

Update group picture with current selected image.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>
  
[[TAPCoreChatRoomManager sharedManager] updateGroupPicture:GROUP_IMAGE roomID:GROUP_ROOM_ID successBlock:^(TAPRoomModel * _Nonnull room) {
    //success update group profile image
} progressBlock:^(CGFloat progress, CGFloat total) {
    //Handle upload image progress
} failureBlock:^(NSError * _Nonnull error) {
    //Failed update group profile image
}];

Parameters GROUP_IMAGE: (UIImage) image of group profile GROUP_ROOM_ID: (String) room ID of group

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.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>

[[TAPCoreChatRoomManager sharedManager] deleteLocalGroupChatRoom:ROOM_ID success:^{
    //Success delete group chat room
} failure:^(NSError * _Nonnull error) {
    //Failed delete group chat room
}];

Parameters ROOM_ID: (NSString) group room ID to be deleted

Delete Group Chat Room

Delete group chat room and clear all chat data and participants.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>

[[TAPCoreChatRoomManager sharedManager] deleteGroupChatRoom:GROUP_ROOM success:^{
    //Success delete group chat room
} failure:^(NSError * _Nonnull error) {
    //Failed delete group chat room
}];

Parameters GROUP_ROOM: (TAPRoomModel) group room to be deleted

Leave Group Chat

Leave from selected group chat.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>
  
[[TAPCoreChatRoomManager sharedManager] leaveGroupChatRoomWithRoomID:GROUP_ROOM_ID success:^{
    //Success leave group chat room
} failure:^(NSError * _Nonnull error) {
    //Failed leave group chat room
}];

Parameters GROUP_ROOM_ID: (String) room ID of group

Add Members to Group Chat

Add selected member(s) to current group chat room.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>
  
[[TAPCoreChatRoomManager sharedManager] addGroupChatMembersWithUserIDArray:PARTICIPANTS_USER_ID_ARRAY roomID:GROUP_ROOM_ID success:^(TAPRoomModel * _Nonnull room) {
    //Success add members to group
} failure:^(NSError * _Nonnull error) {
    //Failed add members to group
}];

Parameters PARTICIPANTS_USER_ID_ARRAY: (Array ) list of participant userIDs GROUP_ROOM_ID: (String) room ID of group

Remove Members from Group Chat

Remove selected member(s) from current group chat room.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>
  
[[TAPCoreChatRoomManager sharedManager] removeGroupChatMembersWithUserIDArray:PARTICIPANTS_USER_ID_ARRAY roomID:GROUP_ROOM_ID success:^(TAPRoomModel * _Nonnull room) {
    //Success remove members from group
} failure:^(NSError * _Nonnull error) {
    //Failed remove members from group
}];

Parameters PARTICIPANTS_USER_ID_ARRAY: (Array ) list of participant userIDs GROUP_ROOM_ID: (String) room ID of group

Promote Group Admin

Promote selected member(s) as admin(s) to the current group chat room.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>
  
[[TAPCoreChatRoomManager sharedManager] promoteGroupAdminsWithUserIDArray:USER_ID_ARRAY roomID:GROUP_ROOM_ID success:^(TAPRoomModel * _Nonnull room) {
    //Success promote member to admin
} failure:^(NSError * _Nonnull error) {
    //Failed promote member to admin
}];

Parameters USER_ID_ARRAY: (Array ) list of userIDs GROUP_ROOM_ID: (String) room ID of group

Demote Group Admin

Demote selected admin(s) to member(s) to the current group chat room.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>
  
[[TAPCoreChatRoomManager sharedManager] demoteGroupAdminsWithUserIDArray:USER_ID_ARRAY roomID:GROUP_ROOM_ID success:^(TAPRoomModel * _Nonnull room) {
    //Success demote admin to member
} failure:^(NSError * _Nonnull error) {
    //Failed demote admin to member
}];

Parameters USER_ID_ARRAY: (Array ) list of userIDs GROUP_ROOM_ID: (String) room ID of group

Get Saved Messages Chat Room

Obtain Saved Messages chat room data.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>

[[TAPCoreChatRoomManager sharedManager] getSavedMessagesChatRoom:^(TAPRoomModel * _Nonnull room) {
   //Success get chat room data
} failure:^(NSError * _Nonnull error) {
   //Failed get chat room data
}];

Send Start Typing

Notify that the active user has started typing in the selected room.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>

[[TAPCoreChatRoomManager sharedManager] sendStartTypingEmitWithRoomID:GROUP_ROOM_ID];

Parameters GROUP_ROOM_ID: (String) room ID of group

Send Stop Typing

Notify that the active user has stopped typing in the selected room.

//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>

[[TAPCoreChatRoomManager sharedManager] sendStopTypingEmitWithRoomID:GROUP_ROOM_ID];

Parameters GROUP_ROOM_ID: (String) room ID of group

Send Text Message

To send a text message to a chat room, use the sendTextMessage:room:start:success:failure: method from the TapCoreMessageManager class.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send text message
[[TAPCoreMessageManager sharedManager] sendTextMessage:MESSAGE_BODY
                                                  room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Use the sendTextMessage:quotedMessage:room:start:success:failure: method to send a text message with quote.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send text message with quote
[[TAPCoreMessageManager sharedManager] sendTextMessage:MESSAGE_BODY
                                         quotedMessage:QUOTED_MESSAGE
                                                  room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Parameters MESSAGE_BODY: (String) content of the message ROOM: (TAPRoomModel) the destination room where the message will be sent QUOTED_MESSAGE: (TAPMessageModel) quote containing another existing message

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send location message
[[TAPCoreMessageManager sharedManager] sendLocationMessageWithLatitude:LATITUDE
                                                             longitude:LONGITUDE
                                                               address:ADDRESS
                                                                  room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed  
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Use the sendLocationMessageWithLatitude:longitude:quotedMessage:address:room:start:success:failure: method to send a location message with quote.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send location message with quote
[[TAPCoreMessageManager sharedManager] sendLocationMessageWithLatitude:LATITUDE
                                                             longitude:LONGITUDE
                                                         quotedMessage:QUOTED_MESSAGE
                                                               address:ADDRESS
                                                                  room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed  
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Parameters LATITUDE: (Float) latitude of the shared location LONGITUDE: (Float) longitude of the shared location ADDRESS: (String) text data containing the location address ROOM: (TAPRoomModel) the destination room where the message will be sent QUOTED_MESSAGE: (TAPMessageModel) quote containing another existing message

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send image using UIImage
[[TAPCoreMessageManager sharedManager] sendImageMessage:IMAGE
                                                caption:CAPTION
                                                  room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // Image upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send image using PHAsset
[[TAPCoreMessageManager sharedManager] sendImageMessageWithAsset:IMAGE_ASSET
                                                         caption:CAPTION
                                                            room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // Image upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send image using image asset URL
[[TAPCoreMessageManager sharedManager] sendImageMessageWithURL:IMAGE_ASSET_URL
                                                       caption:CAPTION
                                                          room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // Image upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send image using remote image URL
[[TAPCoreMessageManager sharedManager] sendImageMessageWithRemoteUrl:IMAGE_URL
                                                             caption:CAPTION
                                                                room:ROOM
                                                       fetchMetadata:FETCH_METADATA
temporaryMessageCreated:^(TAPMessageModel * _Nonnull message) {
    // Temporary message was created while fetching metadata
    // This callback will be called when FETCH_METADATA is true
}
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Use the sendImageMessage: or sendImageMessageWithAsset: or sendImageMessageWithRemoteUrl: method with extra parameter to send an image message with quote.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send image using UIImage with quote
[[TAPCoreMessageManager sharedManager] sendImageMessage:IMAGE
                                          quotedMessage:QUOTED_MESSAGE
                                                caption:CAPTION
                                                  room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // Image upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send image using PHAsset with quote
[[TAPCoreMessageManager sharedManager] sendImageMessageWithAsset:IMAGE_ASSET
                                                   quotedMessage:QUOTED_MESSAGE
                                                         caption:CAPTION
                                                            room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // Image upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send image using image asset URL with quote
[[TAPCoreMessageManager sharedManager] sendImageMessageWithURL:IMAGE_ASSET_URL
                                                 quotedMessage:QUOTED_MESSAGE
                                                       caption:CAPTION
                                                          room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // Image upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send image using remote image URL with quote
[[TAPCoreMessageManager sharedManager] sendImageMessageWithRemoteUrl:IMAGE_URL
                                                             caption:CAPTION
                                                                room:ROOM
                                                       quotedMessage:QUOTED_MESSAGE
                                                       fetchMetadata:FETCH_METADATA
temporaryMessageCreated:^(TAPMessageModel * _Nonnull message) {
    // Temporary message was created while fetching metadata
    // This callback will be called when FETCH_METADATA is true
}
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Parameters IMAGE: (UIImage) selected image with UIImage type IMAGE_ASSET: (PHAsset) selected image asset data IMAGE_ASSET_URL: (NSURL) local URL of the image asset IMAGE_URL: (String) remote URL of the image CAPTION: (String) caption for the image ROOM: (TAPRoomModel) the destination room where the message will be sent QUOTED_MESSAGE: (TAPMessageModel) quote containing another existing message FETCH_METADATA: (BOOL) inserts metadata from remote URL to the constructed message when true

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send video using video asset (PHAsset)
[[TAPCoreMessageManager sharedManager] sendVideoMessageWithAsset:VIDEO_ASSET
                                                         caption:CAPTION
                                                            room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
progress:^(TAPMessageModel * _Nullable message, TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // Video upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send video using video asset URL
[[TAPCoreMessageManager sharedManager] sendVideoMessageWithVideoAssetURL:VIDEO_ASSET_URL
                                                                 caption:CAPTION
                                                                    room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
progress:^(TAPMessageModel * _Nullable message, TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // Video upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send video using remote video URL
[[TAPCoreMessageManager sharedManager] sendVideoMessageWithRemoteUrl:VIDEO_URL
                                                             caption:CAPTION
                                                                room:ROOM 
                                                       fetchMetaData:FETCH_METADATA
temporaryMessageCreated:^(TAPMessageModel * _Nonnull message) {
    // Temporary message was created while fetching metadata
    // This callback will be called when FETCH_METADATA is true
}
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Use the send video method with extra parameter to send a video message with quote.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send video using video asset (PHAsset) with quote
[[TAPCoreMessageManager sharedManager] sendVideoMessageWithAsset:VIDEO_ASSET
                                                   quotedMessage:QUOTED_MESSAGE
                                                         caption:CAPTION
                                                            room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
progress:^(TAPMessageModel * _Nullable message, TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // Video upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send video using video asset URL with quote
[[TAPCoreMessageManager sharedManager] sendVideoMessageWithVideoAssetURL:VIDEO_ASSET_URL
                                                           quotedMessage:QUOTED_MESSAGE
                                                                 caption:CAPTION
                                                                    room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
progress:^(TAPMessageModel * _Nullable message, TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // Video upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send video using remote video URL with quote
[[TAPCoreMessageManager sharedManager] sendVideoMessageWithRemoteUrl:VIDEO_URL
                                                             caption:CAPTION
                                                                room:ROOM
                                                       quotedMessage:QUOTED_MESSAGE
                                                       fetchMetaData:FETCH_METADATA
temporaryMessageCreated:^(TAPMessageModel * _Nonnull message) {
    // Temporary message was created while fetching metadata
    // This callback will be called when FETCH_METADATA is true
}
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Parameters VIDEO_ASSET: (PHAsset) selected videos asset data VIDEO_ASSET_URL: (NSURL) local URL of the video asset VIDEO_URL: (String) remote URL of the video CAPTION: (String) caption for the video ROOM: (TAPRoomModel) the destination room where the message will be sent QUOTED_MESSAGE: (TAPMessageModel) quote containing another existing message FETCH_METADATA: (BOOL) inserts metadata from remote URL to the constructed message when true

Send File Message

You can also send a file to a chat room using sendFileMessageWithFileURI: or sendFileMessageWithRemoteUrl:.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send file using file asset URL
[[TAPCoreMessageManager sharedManager] sendFileMessageWithFileURI:FILE_ASSET_URL
                                                             room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
} 
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // File upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send file using remote file URL
[[TAPCoreMessageManager sharedManager] sendFileMessageWithRemoteUrl:FILE_URL
                                                            caption:CAPTION
                                                               room:ROOM
                                                      fetchMetadata:FETCH_METADATA
temporaryMessageCreated:^(TAPMessageModel * _Nonnull message) {
    // Temporary message was created while fetching metadata
    // This callback will be called when FETCH_METADATA is true
}
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send file using remote file URL, file name, and mime type
[[TAPCoreMessageManager sharedManager] sendFileMessageWithRemoteUrl:FILE_URL
                                                            caption:CAPTION
                                                               room:ROOM
                                                           fileName:FILE_NAME
                                                           mimeType:MIME_TYPE
                                                      fetchMetadata:FETCH_METADATA
temporaryMessageCreated:^(TAPMessageModel * _Nonnull message) {
    // Temporary message was created while fetching metadata
    // This callback will be called when FETCH_METADATA is true
}
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Use the send file method with extra parameter to send a file message with quote.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send file using file asset URL with quote
[[TAPCoreMessageManager sharedManager] sendFileMessageWithFileURI:FILE_ASSET_URL
                                                    quotedMessage:QUOTED_MESSAGE
                                                             room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
} 
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // File upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send file using remote file URL with quote
[[TAPCoreMessageManager sharedManager] sendFileMessageWithRemoteUrl:FILE_URL
                                                            caption:CAPTION
                                                               room:ROOM
                                                      quotedMessage:QUOTED_MESSAGE
                                                      fetchMetadata:FETCH_METADATA
temporaryMessageCreated:^(TAPMessageModel * _Nonnull message) {
    // Temporary message was created while fetching metadata
    // This callback will be called when FETCH_METADATA is true
}
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send file using remote file URL, file name, and mime type with quote
[[TAPCoreMessageManager sharedManager] sendFileMessageWithRemoteUrl:FILE_URL
                                                            caption:CAPTION
                                                               room:ROOM
                                                      quotedMessage:QUOTED_MESSAGE
                                                           fileName:FILE_NAME
                                                           mimeType:MIME_TYPE
                                                      fetchMetadata:FETCH_METADATA
temporaryMessageCreated:^(TAPMessageModel * _Nonnull message) {
    // Temporary message was created while fetching metadata
    // This callback will be called when FETCH_METADATA is true
}
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Parameters FILE_ASSET_URL: (NSURL) file path of the selected file FILE_URL: (String) remote URL of the video CAPTION: (String) caption for the video ROOM: (TAPRoomModel) the destination room where the message will be sent QUOTED_MESSAGE: (TAPMessageModel) quote containing another existing message FILE_NAME: (String) file name to be included in message data MIME_TYPE: (String) mime type to be included in message data, set to empty to fetch default mime type from the provided URL FETCH_METADATA: (BOOL) inserts metadata from remote URL to the constructed message when true

Send Voice Message

You can also send a voice note to a chat room using the sendVoiceMessageWithFileURI: method with a provided FILE_URI (NSURL).

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] sendVoiceMessageWithFileURI:AUDIO_ASSET_URL
                                                              room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // File upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Use the sendVoiceMessageWithFileURI: method with extra parameter to send a voice message with quote.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] sendVoiceMessageWithFileURI:AUDIO_ASSET_URL
                                                     quotedMessage:QUOTED_MESSAGE
                                                              room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // File upload is in progress
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Parameters AUDIO_ASSET_URL: (NSURL) file path of the selected audio CAPTION: (String) caption for the video ROOM: (TAPRoomModel) the destination room where the message will be sent QUOTED_MESSAGE: (TAPMessageModel) quote containing another existing message

You can send a link message, which is usually composed of a text message with URL on the body, using the sendLinkMessage: method.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send link message
[[TAPCoreMessageManager sharedManager] sendLinkMessage:MESSAGE_BODY
                                                  room:ROOM
                                                  urls:URLS
                                                 title:TITLE
                                           description:DESCRIPTION
                                                 image:IMAGE
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    //Failed send link message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send link message with additional metadata parameters
[[TAPCoreMessageManager sharedManager] sendLinkMessage:MESSAGE_BODY
                                                  room:ROOM
                                                  urls:URLS
                                                 title:TITLE
                                           description:DESCRIPTION
                                                 image:IMAGE
                                              siteName:SITE_NAME
                                                  type:TYPE
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Use the sendLinkMessage: method with extra parameters to send a link message with quote.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send link message with quote
[[TAPCoreMessageManager sharedManager] sendLinkMessage:MESSAGE_BODY
                                         quotedMessage:QUOTED_MESSAGE
                                                  room:ROOM
                                                  urls:URLS
                                                 title:TITLE
                                           description:DESCRIPTION
                                                 image:IMAGE
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send link message with quote and additional metadata parameters
[[TAPCoreMessageManager sharedManager] sendLinkMessage:MESSAGE_BODY
                                         quotedMessage:QUOTED_MESSAGE
                                                  room:ROOM
                                                  urls:URLS
                                                 title:TITLE
                                           description:DESCRIPTION
                                                 image:IMAGE
                                              siteName:SITE_NAME
                                                  type:TYPE
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was sent successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to send message
}];

Parameters MESSAGE_BODY: (String) content of the message ROOM: (TAPRoomModel) the destination room where the message will be sent QUOTED_MESSAGE: (TAPMessageModel) quote containing another existing message 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

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Forward a message
[[TAPCoreMessageManager sharedManager] sendForwardedMessage:MESSAGE_TO_FORWARD 
                                                       room:ROOM
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
} 
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {

} 
success:^(TAPMessageModel * _Nonnull message) {
    // Message was forwarded successfully
} 
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to forward message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Forward multiple messages at once
[[TAPCoreMessageManager sharedManager] sendForwardedMessageWithMessageArray:MESSAGES_TO_FORWARD
                                                                       room:ROOM 
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
} 
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {

} 
success:^(TAPMessageModel * _Nonnull message) {
    // Message was forwarded successfully
} 
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to forward message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Forward a message to multiple chat rooms
[[TAPCoreMessageManager sharedManager] sendForwardedMessage:MESSAGE_TO_FORWARD 
                                            toMultipleRooms:ROOMS
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
} 
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {

} 
success:^(TAPMessageModel * _Nonnull message) {
    // Message was forwarded successfully
} 
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to forward message
}];
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Forward multiple messages to multiple chat rooms at once
[[TAPCoreMessageManager sharedManager] sendForwardedMessageWithMessageArray:MESSAGES_TO_FORWARD 
                                                            toMultipleRooms:ROOMS
start:^(TAPMessageModel * _Nonnull message) {
    // Message was constructed
} 
progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    // Progress forward message
} 
success:^(TAPMessageModel * _Nonnull message) {
    // Message was forwarded successfully
} 
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    // Failed to forward message
}];

Parameters MESSAGE_TO_FORWARD: (TAPMessageModel) existing message to be forwarded MESSAGES_TO_FORWARD: (NSArray<TAPMessageModel>) array of messages to be forwarded ROOM: (TAPRoomModel) the destination room where the message will be forwarded ROOMS: (NSArray<TAPRoomModel>) list of destination rooms where the message will be forwarded

Construct TapTalk.io Message Model

You can construct your own customized message model to be used in chat as shown below.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

TAPMessageModel *constructedMessage = [[TAPCoreMessageManager sharedManager] constructTapTalkMessageModelWithRoom:ROOM messageBody:MESSAGE_BODY messageType:MESSAGE_TYPE messageData:MESSAGE_DATA];

To construct a custom message with quote, use the constructTapTalkMessageModelWithRoom:quotedMessage: method.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

TAPMessageModel *constructedMessage = [[TAPCoreMessageManager sharedManager] constructTapTalkMessageModelWithRoom:ROOM quotedMessage:QUOTED_MESSAGE messageBody:MESSAGE_BODY messageType:MESSAGE_TYPE messageData:MESSAGE_DATA];

Parameters MESSAGE_BODY: (String) content of the message ROOM: (TAPRoomModel) the destination room where the message will be sent MESSAGE_TYPE: (Integer) type of your custom message, check the Message Type page for more information MESSAGE_DATA: (NSDictionary) custom data for the message (optional) QUOTED_MESSAGE: (TAPMessageModel) quote of the new message model containing another existing message

Note: you are free to put any data that you need for your custom message in the MESSAGE_DATA parameter, to obtain message data from a TAPMessageModel, look into the data property of TAPMessageModel (message.data).

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] sendCustomMessageWithMessageModel:CUSTOM_MESSAGE start:^(TAPMessageModel * _Nonnull message) {
    //Obtain constructed forwarded message and start sending
} success:^(TAPMessageModel * _Nonnull message) {
    //Success send custom message
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    //Failed send custom message
}];

Parameters CUSTOM_MESSAGE: (TAPMessageModel) the message to be sent, see the Construct TapTalk.io Message Model section to construct a custom message

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] editMessage:self.currentEditingMessage
                                       updatedText:currentMessage
start:^(TAPMessageModel * _Nonnull message) {
    // Message is being processed
}
success:^(TAPMessageModel * _Nonnull message) {
    // Message was edited successfully
}
failure:^(TAPMessageModel * _Nullable message, NSError *error) {
    // Failed to edit message
}];

Parameters MESSAGE_MODEL: (TAPMessageModel) the message to be updated UPDATED_TEXT: (NSString) new text to replace the body and caption of the message

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
  
[[TAPCoreMessageManager sharedManager] deleteMessage:MESSAGE_MODEL success:^{
    
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    
}];

Parameters MESSAGE_MODEL: (TAPMessageModel) the message to be deleted

Delete Message from Local Cache

To delete a message from local cache, call deleteLocalMessageWithLocalID: from TapCoreMessageManager class.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
  
[[TAPCoreMessageManager sharedManager] deleteLocalMessageWithLocalID:MESSAGE_LOCAL_ID success:^{
    
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    
}];

Parameters MESSAGE_LOCAL_ID: (String) local ID of the message to delete

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
  
[[TAPCoreMessageManager sharedManager] cancelMessageFileUpload:MESSAGE success:^{
    
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    
}];

Parameters MESSAGE: (TAPMessageModel) pending message with ongoing file upload

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

//Download FILE message
[[TAPCoreMessageManager sharedManager] downloadMessageFile:MESSAGE start:^{
    
} progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    
} success:^(NSData * _Nonnull fileData) {
  //Success download file message and return fileData (NSData)
    
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    
}];


//Download IMAGE message
[[TAPCoreMessageManager sharedManager] downloadMessageImage:MESSAGE start:^{
    
} progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    
} success:^(UIImage * _Nonnull fullImage) {
  //Success download image message and return fullImage (UIImage)
    
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    
}];


//Download VIDEO message
[[TAPCoreMessageManager sharedManager] downloadMessageVideo:MESSAGE start:^{
    
} progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
    
} success:^(NSData * _Nonnull fileData) {
  //Success download video message and return fileData (NSData)
    
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    
}];

Parameters MESSAGE: (TAPMessageModel) existing message to download the file from

Cancel Message File Download

You can cancel download message with type such as Image, Video, and File by calling the cancelMessageFileDownload: method.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
  
[[TAPCoreMessageManager sharedManager] cancelMessageFileDownload:MESSAGE success:^{
    
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
    
}];

Parameters MESSAGE: (TAPMessageModel) selected message with ongoing file download

Mark Message as Delivered

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

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] markMessageAsRead:MESSAGE];

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:.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Mark single message as read
[[TAPCoreMessageManager sharedManager] markMessageAsRead:MESSAGE];

// Mark multiple messages as read
[[TAPCoreMessageManager sharedManager] markMessageAsRead:MESSAGE_ARRAY];

// Mark multiple messages as read with completion handler
[[TAPCoreMessageManager sharedManager] markMessageAsRead:MESSAGE_ARRAY 
success:^(NSArray<NSString *> *updatedMessageIDs){
    // updatedMessageIDs contains message IDs that were successfully marked as read
} 
failure:^(NSError *error) {
             
}];

Parameters MESSAGE: (TAPMessageModel) existing message to be marked as read MESSAGE_ARRAY: (NSArray<TAPMessageModel>) array of message models to be marked as read

Mark All Chat Room Messages as Read

To quickly mark all unread messages in a chat room as read, call markAllMessageInRoomAsRead: method.

// Mark all unread messages in specified chat room as read
[[TAPCoreMessageManager sharedManager] markAllMessagesInRoomAsReadWithRoomID:ROOM_ID];


// Mark all unread messages in specified chat room as read with completion listener
[[TAPCoreMessageManager sharedManager] markAllMessagesInRoomAsReadWithRoomID:ROOM_ID
success:^(NSArray<NSString *> *updatedMessageIDs){
    // updatedMessageIDs contains message IDs that were successfully marked as read
} 
failure:^(NSError *error) {
             
}];

Parameters ROOM_ID: (NSString) room ID of the messages to be marked as read

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[TAPCoreMessageManager sharedManager] getLocalMessagesWithRoomID:ROOM_ID success:^(NSArray<TAPMessageModel *> * _Nonnull messageArray) {
        
} failure:^(NSError * _Nonnull error) {
    
}];

Parameters ROOM_ID: (NSString) the room ID to retrieve the messages for

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] getOlderMessagesBeforeTimestamp:MAX_CREATED_TIMESTAMP roomID:ROOM_ID numberOfItems:NUMBER_OF_ITEMS success:^(NSArray<TAPMessageModel *> * _Nonnull messageArray, BOOL hasMoreData) {
  //hasMoreData will return true if more messages that have not been retrieved remain in the chat room
  
} failure:^(NSError * _Nonnull error) {
    
}];

Parameters ROOM_ID: (NSString) the room ID to retrieve the messages for MAX_CREATED_TIMESTAMP: (NSNumber) the maximum created time of the messages to retrieve, in milliseconds NUMBER_OF_ITEMS: (NSNumber) maximum limit of the number of messages to retrieve

Get Newer Messages from Chat Room

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

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] getNewerMessagesAfterTimestamp:MIN_CREATED_TIMESTAMP lastUpdatedTimestamp:LAST_UPDATE_TIMESTAMP roomID:ROOM_ID numberOfItems:NUMBER_OF_ITEMS success:^(NSArray<TAPMessageModel *> * _Nonnull messageArray) {
  
} failure:^(NSError * _Nonnull error) {
    
}];

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] getNewerMessagesWithRoomID:ROOM_ID success:^(NSArray<TAPMessageModel *> * _Nonnull messageArray) {
  
} failure:^(NSError * _Nonnull error) {
    
}];

Parameters ROOM_ID: (NSString) the room ID to retrieve the messages for MIN_CREATED_TIMESTAMP: (NSNumber) the minimum created time of the messages to retrieve, in millisecond LAST_UPDATE_TIMESTAMP: (NSNumber) the minimum updated time of the messages to retrieve, in milliseconds NUMBER_OF_ITEMS: (NSNumber) maximum limit of the number of messages to retrieve

Get All Messages from Chat Room

You may also retrieve all available messages from a chat room using the getAllMessagesWithRoomID: method.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[TAPCoreMessageManager sharedManager] getAllMessagesWithRoomID:ROOM_ID successLocalMessages:^(NSArray<TAPMessageModel *> * _Nonnull messageArray) {
        
} successAllMessages:^(NSArray<TAPMessageModel *> * _Nonnull allMessagesArray, NSArray<TAPMessageModel *> * _Nonnull olderMessagesArray, NSArray<TAPMessageModel *> * _Nonnull newerMessagesArray) {
    
} failure:^(NSError * _Nonnull error) {
    
}];

Parameters ROOM_ID: (NSString) the room ID to retrieve the messages for

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[TAPCoreMessageManager sharedManager] getUnreadMessagesFromRoom:ROOM_ID success:^(NSArray<TAPMessageModel *> * _Nonnull unreadMessageArray) {
        
} failure:^(NSError * _Nonnull error) {
    
}];

Parameters ROOM_ID: (NSString) the room ID to retrieve the messages from

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[TAPCoreMessageManager sharedManager] getMediaMessagesFromRoom:ROOM_ID 
                                                 lastTimestamp:LAST_TIMESTAMP 
                                                  numberOfItem:NUMBER_OF_ITEM 
    success:^(NSArray<TAPMessageModel *> * _Nonnull unreadMessageArray) {
        
} 
    failure:^(NSError * _Nonnull error) {
    
}];

Parameters ROOM_ID: (NSString) the room ID to retrieve the messages from LAST_TIMESTAMP: (NSNumber) the maximum created time of the messages to retrieve, in milliseconds NUMBER_OF_ITEMS: (NSNumber) maximum limit of the number of messages to retrieve

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[TAPCoreMessageManager sharedManager] searchLocalMessageWithKeyword:KEYWORD success:^(NSArray<TAPMessageModel *> * _Nonnull messageArray) {
    // Returns filtered messages obtained from local storage    
} failure:^(NSError * _Nonnull error) {
    
}];

Parameters KEYWORD: (NSString) search keyword to filter message body

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Star single message
[[TAPCoreMessageManager sharedManager] starMessageWithMessageID:MESSAGE_ID 
                                                         roomID:ROOM_ID 
success:^(NSArray<NSString *> * _Nonnull starredMessagesIDs) {
    // Returns list of messageID of starred messages
} 
failure:^(NSError * _Nonnull error) {
                            
}];


// Star multiple messages
[[TAPCoreMessageManager sharedManager] starMessagesWithMessageIDs:MESSAGE_IDS 
                                                           roomID:ROOM_ID 
success:^(NSArray<NSString *> * _Nonnull starredMessagesIDs) {
    // Returns list of messageID of starred messages
} 
failure:^(NSError * _Nonnull error) {
                            
}];


// Unstar single message
[[TAPCoreMessageManager sharedManager] unstarMessageWithMessageID:MESSAGE_ID 
                                                           roomID:ROOM_ID 
success:^(NSArray<NSString *> * _Nonnull unstarredMessagesIDs) {
    // Returns list of messageID of unstarred messages
} 
failure:^(NSError * _Nonnull error) {
                            
}];


// Unstar multiple messages
[[TAPCoreMessageManager sharedManager] unstarMessagesWithMessageIDs:MESSAGE_IDS 
                                                             roomID:ROOM_ID 
success:^(NSArray<NSString *> * _Nonnull unstarredMessagesIDs) {
    // Returns list of messageID of unstarred messages
} 
failure:^(NSError * _Nonnull error) {
                            
}];

Parameters ROOM_ID: (NSString) room ID, can be obtained from the message's room model MESSAGE_ID: (NSString) unique server ID from the message MESSAGE_IDS: (NSArray<NSString>) list containing message IDs to be starred/unstarred

Get Starred Messages

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

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] getStarredMessageIDsWithRoomID:ROOM_ID 
success:^(NSArray<NSString *> * _Nonnull starredMessagesIDs) {
    // Returns list of messageID of starred messages
} 
failure:^(NSError * _Nonnull error) {
        
}];

Parameters ROOM_ID: (NSString) ID of the target room

A method to obtain the full message model list of the starred messages with pagination is also provided.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] getStarredMessagesWithRoomID:ROOM_ID 
                                                         pageNumber:PAGE_NUMBER
                                                      numberOfItems:NUMBER_OF_ITEMS 
success:^(NSArray<TAPMessageModel *> * _Nonnull starredMessagesArray, BOOL hasMoreData) {
    // hasMoreData will return YES if the room has remaining starred messages that have not been retrieved
} 
failure:^(NSError * _Nonnull error) {
    
}];

Parameters ROOM_ID: (NSString) ID of the target room PAGE_NUMBER: (NSInteger) the number of page to retrieve the items NUMBER_OF_ITEMS: (NSInteger) number of items to be retrieved

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Pin single message
[[TAPCoreMessageManager sharedManager] pinMessageWithMessageID:MESSAGE_ID 
                                                        roomID:ROOM_ID 
success:^(NSArray<NSString *> * _Nonnull pinnedMessagesIDs) {
    // Returns list of messageID of pinned messages
} 
failure:^(NSError * _Nonnull error) {
                            
}];


// Pin multiple messages
[[TAPCoreMessageManager sharedManager] pinMessagesWithMessageIDs:MESSAGE_IDS 
                                                          roomID:ROOM_ID 
success:^(NSArray<NSString *> * _Nonnull pinnedMessagesIDs) {
    // Returns list of messageID of pinned messages
} 
failure:^(NSError * _Nonnull error) {
                            
}];


// Unpin single message
[[TAPCoreMessageManager sharedManager] unpinMessageWithMessageID:MESSAGE_ID 
                                                          roomID:ROOM_ID 
success:^(NSArray<NSString *> * _Nonnull unpinnedMessagesIDs) {
    // Returns list of messageID of unpinned messages
} 
failure:^(NSError * _Nonnull error) {
                            
}];


// Unpin multiple messages
[[TAPCoreMessageManager sharedManager] unpinMessagesWithMessageIDs:MESSAGE_IDS 
                                                            roomID:ROOM_ID 
success:^(NSArray<NSString *> * _Nonnull unpinnedMessagesIDs) {
    // Returns list of messageID of unpinned messages
} 
failure:^(NSError * _Nonnull error) {
                            
}];

Parameters ROOM_ID: (NSString) room ID, can be obtained from the message's room model MESSAGE_ID: (NSString) unique server ID from the message MESSAGE_IDS: (NSArray<NSString>) list containing message IDs to be pinned/unpinned

Get Pinned Messages

You can use the method below get a list of message IDs of pinned messages in a chat room.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] getPinnedMessageIDsWithRoomID:ROOM_ID 
success:^(NSArray<NSString *> * _Nonnull pinnedMessagesIDs) {
    // Returns list of messageID of pinned messages
} 
failure:^(NSError * _Nonnull error) {
        
}];

Parameters ROOM_ID: (NSString) ID of the target room

A method to obtain the full message model list of the pinned messages with pagination is also provided.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] getPinnedMessagesWithRoomID:ROOM_ID 
                                                        pageNumber:PAGE_NUMBER
                                                     numberOfItems:NUMBER_OF_ITEMS 
success:^(NSArray<TAPMessageModel *> * _Nonnull pinnedMessagesArray, BOOL hasMoreData) {
    // hasMoreData will return YES if the room has remaining pinned messages that have not been retrieved
} 
failure:^(NSError * _Nonnull error) {
    
}];

Parameters ROOM_ID: (NSString) ID of the target room PAGE_NUMBER: (NSInteger) the number of page to retrieve the items NUMBER_OF_ITEMS: (NSInteger) number of items to be retrieved

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] getSharedContentMessagesWithRoomID:ROOM_ID 
                                                               maxCreated:MAX_CREATED_TIMESTAMP
                                                               minCreated:MAX_CREATED_TIMESTAMP
success:^(NSArray<TAPMessageModel *> * mediaMessagesArray, NSArray<TAPMessageModel *> * fileMessagesArray, NSArray<TAPMessageModel *> * linkMessagesArray) {
    // mediaMessagesArray contains image and video messages
    // fileMessagesArray contains file/document messages
    // linkMessagesArray contains link messages
} 
failure:^(NSError * _Nonnull error) {
    
}];

Parameters ROOM_ID: (NSString) ID of the target room MIN_CREATED_TIMESTAMP: (long) smallest created time of the messages to retrieve, use 0L to retrieve up to the oldest message in the room MAX_CREATED_TIMESTAMP: (long) largest created time of the messages to retrieve, use current timestamp to retrieve up to the newest message in the room

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.

// import TapTalk Chat Room Manager
#import <TapTalk/TapCoreChatRoomManager.h>

[[TAPCoreChatRoomManager sharedManager] deleteAllChatRoomMessages:ROOM_ID success:^(NSArray * _Nonnull deletedRoomIDs) {
    // Successfully deleted all messages in the chat room
}
failure:^(NSError * _Nonnull error) {
        
}];

Parameters ROOM_ID: (NSString) ID of the target room

Create Scheduled Message

You can schedule a constructed message model to be delivered at a specified time to a chat room.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Construct a TapTalk message model to be scheduled
TAPMessageModel *constructedMessage = [[TAPCoreMessageManager sharedManager] constructTapTalkMessageModelWithRoom:ROOM 
                                                                                                      messageBody:MESSAGE_BODY 
                                                                                                      messageType:MESSAGE_TYPE 
                                                                                                      messageData:MESSAGE_DATA];

// Schedule the constructed message
[[TAPCoreMessageManager sharedManager] createScheduleMessage:constructedMessage
                                                scheduleTime:TIMESTAMP
success:^(TAPMessageModel * _Nonnull message) {
    // Successfully created a scheduled message
}
failure:^(NSError * _Nonnull error) {
    
}];

Parameters MESSAGE_BODY: (String) content of the message ROOM: (TAPRoomModel) the destination room where the message will be sent MESSAGE_TYPE: (Integer) type of your custom message, check the Message Type page for more information MESSAGE_DATA: (NSDictionary) custom data for the message (optional) QUOTED_MESSAGE: (TAPMessageModel) quote of the new message model containing another existing message TIMESTAMP: (NSNumber) time when the message will be delivered to the destination room (long value)

Get Scheduled Messages

You may then retrieve the list of created scheduled messages that have not yet been delivered in a chat room.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] getScheduledMessagesWithRoomID:ROOM_ID
success:^(NSArray<TAPScheduledMessageModel *> * _Nonnull scheduleMessageArray) {
    // Successfully retrieved scheduled messages
}
failure:^(NSError * _Nonnull error) {
    
}];

Parameters ROOM_ID: (NSString) ID of the destination chat room

Send Scheduled Message Now

You may also send a previously created scheduled message immediately to the recipient.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

// Send a scheduled message immediately
[[TAPCoreMessageManager sharedManager] sendScheduledMessageNow:SCHEDULED_MESSAGE_ID
                                                        roomID:ROOM_ID
success:^(NSArray<NSNumber *> * _Nonnull sentIDs) {
    // Successfully sent scheduled message
}
failure:^(NSError * _Nonnull error) {
    
}];

// Send multiple scheduled messages immediately
[[TAPCoreMessageManager sharedManager] sendScheduledMessagesNow:SCHEDULED_MESSAGE_IDS
                                                         roomID:ROOM_ID
success:^(NSArray<NSNumber *> * _Nonnull sentIDs) {
    // Successfully sent scheduled messages
}
failure:^(NSError * _Nonnull error) {
    
}];

Parameters SCHEDULED_MESSAGE_ID: (NSNumber) ID of the previously created scheduled message SCHEDULED_MESSAGE_IDS: (NSArray<NSNumber>) array of scheduled message IDs ROOM_ID: (NSString) ID of the destination chat room

Edit Scheduled Message Time

To change the deliver time of a previously created scheduled message, use the editScheduledMessageTime: method from TAPCoreMessageManager.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] editScheduledMessageTime:SCHEDULED_MESSAGE_ID 
                                                  scheduledTime:TIMESTAMP
success:^(BOOL isEditTimeSuccess) {
    // Successfully edited scheduled message
}
failure:^(NSError * _Nonnull error) {
    
}];

Parameters SCHEDULED_MESSAGE_ID: (NSNumber) ID of the previously created scheduled message TIMESTAMP: (NSNumber) time when the message will be delivered to the destination room (long value)

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.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] editScheduledMessageContent:SCHEDULED_MESSAGE_ID
                                                    updatedMessage:MESSAGE
success:^(BOOL isEditContentSuccess) {
    // Successfully edited scheduled message
}
failure:^(NSError * _Nonnull error) {
    
}];

Parameters SCHEDULED_MESSAGE_ID: (NSNumber) ID of the previously created scheduled message MESSAGE: (TAPMessageModel) message model with updated values

Delete Scheduled Message

To cancel sending a scheduled message that has not been delivered, you can delete it using deleteScheduledMessage method.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] deleteScheduledMessage:SCHEDULED_MESSAGE_ID
                                                       roomID:ROOM_ID
success:^(NSArray<NSNumber *> * _Nonnull deletedIDs) {
    // Successfully deleted scheduled message
}
failure:^(NSError * _Nonnull error) {
    
}];

[[TAPCoreMessageManager sharedManager] deleteScheduledMessages:SCHEDULED_MESSAGE_IDS
                                                        roomID:ROOM_ID
success:^(NSArray<NSNumber *> * _Nonnull deletedIDs) {
    // Successfully deleted scheduled messages
}
failure:^(NSError * _Nonnull error) {
    
}];

Parameters SCHEDULED_MESSAGE_ID: (NSNumber) ID of the previously created scheduled message SCHEDULED_MESSAGE_IDS: (NSArray<NSNumber>) array of scheduled message IDs ROOM_ID: (NSString) ID of the destination chat room

Get Message Details

You can retrieve info about a message's recipients that has read or received the message.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] getMessageDetails:MESSAGE_ID
success:^(TAPMessageModel *message, NSArray<TapMessageRecipientModel *> *deliveredTo, NSArray<TapMessageRecipientModel *> *readBy) {
    // Successfully retrieved message info
    // message: the message model
    // deliveredTo: list of recipients that has received the message
    // readBy: list of recipients that has read the message
}
failure:^(NSError * _Nonnull error) {
    
}];

Parameters MESSAGE_ID: (String) unique server ID from the message

Get Message Total Read Count

You can also retrieve a message's total read count from a non-personal room.

// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>

[[TAPCoreMessageManager sharedManager] getMessageTotalRead:MESSAGE_ID
success:^(NSInteger readCount) {
    // Successfully retrieved message read count
}
failure:^(NSError * _Nonnull error) {
    
}];

Parameters MESSAGE_ID: (String) unique server ID from the message

Last updated

#621:

Change request updated