Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
// Join a public groupCometChat.joinGroup(GUID: "GUID", groupType: .public, password: nil, onSuccess: { group in }, onError: { error in })// Join a password-protected groupCometChat.joinGroup(GUID: "GUID", groupType: .password, password: "password123", onSuccess: { group in }, onError: { error in })// Listen for member joined events via CometChatGroupDelegatefunc onGroupMemberJoined(action: ActionMessage, joinedUser: User, joinedGroup: Group) { }
Join a group to start sending and receiving messages in it. Public groups can be joined freely, password groups require the correct password, and private groups require an admin to add you (no direct join).
let guid = "cometchat-guid-11"let password: String? = nil // mandatory in case of password protected group typeCometChat.joinGroup(GUID: guid, groupType: .public, password: nil, onSuccess: { (group) in print("Group joined successfully. " + group.stringValue())}, onError: { (error) in print("Group joining failed with error:" + error!.errorDescription)})
NSString *guid = @"cometchat-guid-101";NSString *password = nil; // mandatory in case of password protected group type[CometChat joinGroupWithGUID:guid groupType:groupTypePublic password:password onSuccess:^(Group * group) { NSLog(@"Group joined successfully: %@", [group stringValue]);} onError:^(CometChatException * error) { NSLog(@"Group joining failed with exception: %@", [error errorDescription]);}];
Parameter
Description
GUID
The GUID of the group to join
groupType
.public, .password, or .private
password
Required for password-protected groups
Once joined, you can send and receive messages in the group. CometChat tracks joined groups — you don’t need to rejoin each session. Check hasJoined on the Group object to verify membership.The method returns a Group object with hasJoined set to true.
@interface ViewController ()<CometChatGroupDelegate>@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; [CometChat setGroupdelegate:self];}- (void)onMemberAddedToGroup:(Action *)action addedBy:(User * _Nonnull)addedBy addedUser:(User * _Nonnull)addedUser addedTo:(Group * _Nonnull)addedTo { // When any member is added in the group this function will be called}@end
Always remove group listeners when they’re no longer needed (e.g., on view dismissal). Failing to remove listeners can cause memory leaks and duplicate event handling.