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 | |
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. |
Returns the room model (TAPRoomModel) of the currently active chat room.
Objective-C
//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>
TAPRoomModel *activeRoom = [[TAPCoreChatRoomManager sharedManager] getActiveChatRoom];
Create a new group chat room with selected group name.
Objective-C
//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 userIDsCreate new personal chat room with recipient user, or obtain chat room data if it already exists.
Objective-C
//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 dataCreate new personal chat room with recipient user ID, or obtain chat room data if it already exists.
Objective-C
//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 recipientCreate a new group chat room with selected group name and group picture.
Objective-C
//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 imageGet group room data from selected group room ID.
Objective-C
//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 groupCreate a new Update existing group chat room data.
Objective-C
//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 groupUpdate group picture with current selected image.
Objective-C
//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 groupDelete 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.
Objective-C
//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 deletedDelete group chat room and clear all chat data and participants.
Objective-C
//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 deletedLeave from selected group chat.
Objective-C
//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 groupAdd selected member(s) to current group chat room.
Objective-C
//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 groupRemove selected member(s) from current group chat room.
Objective-C
//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 groupPromote selected member(s) as admin(s) to the current group chat room.
Objective-C
//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 groupDemote selected admin(s) to member(s) to the current group chat room.
Objective-C
//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 groupObtain Saved Messages chat room data.
Objective-C
//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
}];
Notify that the active user has started typing in the selected room.
Objective-C
//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>
[[TAPCoreChatRoomManager sharedManager] sendStartTypingEmitWithRoomID:GROUP_ROOM_ID];
Parameters
GROUP_ROOM_ID
: (String) room ID of groupNotify that the active user has stopped typing in the selected room.
Objective-C
//import TapTalk Chat Room Manager
#import <TapTalk/TAPCoreChatRoomManager.h>
[[TAPCoreChatRoomManager sharedManager] sendStopTypingEmitWithRoomID:GROUP_ROOM_ID];
Parameters
GROUP_ROOM_ID
: (String) room ID of groupTo send a text message to a chat room, use the
sendTextMessage:room:start:success:failure:
method from the TapCoreMessageManager class.Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
[[TAPCoreMessageManager sharedManager] sendTextMessage:MESSAGE_BODY room:ROOM start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed text message and start sending
} success:^(TAPMessageModel * _Nonnull message) {
//Success send text message
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send text message
}];
Use the
sendTextMessage:quotedMessage:room:start:success:failure:
method to send a text message with quote.Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
[[TAPCoreMessageManager sharedManager] sendTextMessage:MESSAGE_BODY quotedMessage:QUOTED_MESSAGE room:ROOM start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed text message and start sending
} success:^(TAPMessageModel * _Nonnull message) {
//Success send text message
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send text 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 messageYou 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.Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
[[TAPCoreMessageManager sharedManager] sendLocationMessageWithLatitude:LATITUDE longitude:LONGITUDE address:ADDRESS room:ROOM start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed location message and start sending
} success:^(TAPMessageModel * _Nonnull message) {
//Success send location message
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send location 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 messageTo send an image to a chat room, you can use
sendImageMessage:
or sendImageMessageWithAsset:
method by providing either UIImage
or PHAsset
as parameter.Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
//Send image using UIImage
[[TAPCoreMessageManager sharedManager] sendImageMessage:IMAGE caption:CAPTION room:ROOM start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed image message and start sending image
} progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
//Progress upload image
} success:^(TAPMessageModel * _Nonnull message) {
//Success send image
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send image
}];
Objective-C
// 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) {
//Obtain constructed image message and start sending image
} progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
//Progress upload image
} success:^(TAPMessageModel * _Nonnull message) {
//Success send image
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send image
}];
Use the
sendImageMessage:
or sendImageMessageWithAsset:
method with extra parameter to send an image message with quote.Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
//Send image using UIImage
[[TAPCoreMessageManager sharedManager] sendImageMessage:IMAGE quotedMessage:QUOTED_MESSAGE caption:CAPTION room:ROOM start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed image message and start sending image
} progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
//Progress upload image
} success:^(TAPMessageModel * _Nonnull message) {
//Success send image
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send image
}];
Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
//Send image using PHAsset
[[TAPCoreMessageManager sharedManager] sendImageMessageWithAsset:IMAGE_ASSET quotedMessage:QUOTED_MESSAGE caption:CAPTION room:ROOM start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed image message and start sending image
} progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
//Progress upload image
} success:^(TAPMessageModel * _Nonnull message) {
//Success send image
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send image
}];
Parameters
IMAGE
: (UIImage) selected image with UIImage
type
IMAGE_ASSET
: (PHAsset) selected image asset data
CAPTION
: (String) caption for the image
ROOM
: (TAPRoomModel) the destination room where the message will be sent
QUOTED_MESSAGE
: (TAPMessageModel) quote containing another existing messageTo send a video to a chat room, you can use
sendVideoMessageWithAsset:
method by providing the VIDEO_ASSET
with PHAsset
type as parameter.Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
[[TAPCoreMessageManager sharedManager] sendVideoMessageWithAsset:VIDEO_ASSET caption:CAPTION room:ROOM start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed video message and start sending video
} progress:^(TAPMessageModel * _Nullable message, TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
//Progress upload video
} success:^(TAPMessageModel * _Nonnull message) {
//Success send video
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send video
}];
Use the
sendVideoMessageWithAsset:
method with extra parameter to send a video message with quote.Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
[[TAPCoreMessageManager sharedManager] sendVideoMessageWithAsset:VIDEO_ASSET quotedMessage:QUOTED_MESSAGE caption:CAPTION room:ROOM start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed video message and start sending video
} progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
//Progress upload video
} success:^(TAPMessageModel * _Nonnull message) {
//Success send video
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send video
}];
Parameters
VIDEO_ASSET
: (PHAsset) selected videos asset data
CAPTION
: (String) caption for the video
ROOM
: (TAPRoomModel) the destination room where the message will be sent
QUOTED_MESSAGE
: (TAPMessageModel) quote containing another existing messageYou can also send a file to a chat room using the
sendFileMessageWithFileURI:
method with a provided FILE_URI
(NSURL
).Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
[[TAPCoreMessageManager sharedManager] sendFileMessageWithFileURI:FILE_URI room:ROOM start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed file message and start sending file
} progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
//Progress upload file
} success:^(TAPMessageModel * _Nonnull message) {
//Success send file
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send file
}];
Use the
sendFileMessageWithFileURI:
method with extra parameter to send a file message with quote.Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
[[TAPCoreMessageManager sharedManager] sendFileMessageWithFileURI:FILE_URI quotedMessage:QUOTED_MESSAGE room:ROOM start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed file message and start sending file
} progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
//Progress upload file
} success:^(TAPMessageModel * _Nonnull message) {
//Success send file
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send file
}];
Parameters
FILE_URI
: (NSURL) file path of the selected file
CAPTION
: (String) caption for the video
ROOM
: (TAPRoomModel) the destination room where the message will be sent
QUOTED_MESSAGE
: (TAPMessageModel) quote containing another existing messageYou can also send a voice note to a chat room using the
sendVoiceMessageWithFileURI:
method with a provided FILE_URI
(NSURL
).Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
[[TAPCoreMessageManager sharedManager] sendVoiceMessageWithFileURI:FILE_URI room:ROOM start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed file message and start sending file
} progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
//Progress upload file
} success:^(TAPMessageModel * _Nonnull message) {
//Success send file
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send file
}];
Use the
sendVoiceMessageWithFileURI:
method with extra parameter to send a file message with quote.Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
[[TAPCoreMessageManager sharedManager] sendVoiceMessageWithFileURI:FILE_URI quotedMessage:QUOTED_MESSAGE room:ROOM start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed file message and start sending file
} progress:^(TAPMessageModel * _Nullable message, CGFloat progress, CGFloat total) {
//Progress upload file
} success:^(TAPMessageModel * _Nonnull message) {
//Success send file
} failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {
//Failed send file
}];
Parameters
FILE_URI
: (NSURL) file path of the selected voice file
CAPTION
: (String) caption for the video
ROOM
: (TAPRoomModel) the destination room where the message will be sent
QUOTED_MESSAGE
: (TAPMessageModel) quote containing another existing messageYou can send a link message, which is usually composed of a text message with URL on the body, using the
sendLinkMessage:
method.Objective-C
// import TapTalk Message Manager
#import <TapTalk/TAPCoreMessageManager.h>
[[TAPCoreMessageManager sharedManager] sendLinkMessage:MESSAGE_BODY
room:ROOM
urls:URLS
title:TITLE
description:DESCRIPTION
image:IMAGE
start:^(TAPMessageModel * _Nonnull message) {
//Obtain constructed text message and start sending
}
success:^(TAPMessageModel * _Nonnull message) {
//Success send link message
}
failure:^(TAPMessageModel * _Nullable message, NSError * _Nonnull error) {