CometChat Developer Documentation

Welcome Ninja!

You'll find comprehensive guides and documentation to help you start working with CometChat as quickly as possible. Let's jump right in!

Get Started    

User Management

Users can be created using one of the below 3 methods:

On-the-fly

To create the users on the go, we provide a method for the iOS SDK named createUser. You can use the method to create a user as shown in the below code sample:

var UID : NSString = "DEMO123" // Required
var name : NSString = "Your Name"  // Required
var avatarURL : NSString = ""
var profileURL : NSString = ""
var role : NSString = ""
        
        
cometChat.createUser(UID, userName:name, userAvatarURL:avatarURL, userProfileURL:profileURL, userRole:role, 
success: {(response) in
            
}, 
failure:{(error) in
           
})
NSString *UID = @"DEMO123";// Required
NSString *name = @"Your Name";  // Required
NSString *avatarURL = @"";
NSString *profileURL = @"";
NSString *role = @"";

[cometchat createUser:UID userName:name userAvatarURL:avatarURL userProfileURL:profileURL userRole:role success:^(NSDictionary *response) {
            NSLog(@"User Created Successfully %@",response);
        } failure:^(NSError *error) {
            NSLog(@"Failed %@",error);
        }];

This method will create the user with the parameters passed if everything is successful and return the details of the user created in the successCallback.
In case the user already exists, it will update the data provided for the for the given UID.

Via Restful API

The second option available to create a user is using the Restful APIs we provide for user management.

Via Admin Panel

The third and the most simple option to create users is by creating the users via the CometChat Administration Panel. All you need to do is log in to the CometChat Admin Panel, and navigate to the Users section in the left pane.