To start with using SDK functionality, you first need to login to your website using SDK. Using SDK you can login by 3 ways
The syntax for the login using username and password is as follows :
login(String SITE_URL, String USER_NAME, String PASSWORD,Callbacks callback)
e.g
cometchat.login("http://www.yoursite.com/cometchat/", "jane", "mypassword", new Callbacks() {
@Override
public void successCallback(JSONObject success) {}
@Override
public void failCallback(JSONObject fail) {}
});
If you have logged in successfully the successCallback will be fired, containing the following response :
{"message": "Login successful"}
Syntax for login using the userID is :
login(String SITE_URL, String USER_ID, Callbacks callback)
The success response will be same as above
To use guest login, make sure that you have enabled the guest login functionality from CometChat administration panel.
The Syntax for the login as guest user is :
guestLogin(String SITE_URL, String GUEST_NAME, Callbacks callback)
The success response will be as follows:
{"message": "Login successful" }
Here the id is the identification number given to the guest.
Calling this function will end the current session and clears user data.
The syntax is as follows :
logout(Callbacks callback)
e.g
cometchat.logout(new Callbacks() {
@Override
public void successCallback(JSONObject response) {}
@Override
public void failCallback(JSONObject response) {}
});
Not finding what you need?
The CometChat team is here to help!