To start using SDK functionality, you first need to login to your website using SDK. Using SDK you can login by 2 ways:
The syntax of this login method is as follows :
login(String USER_NAME, String PASSWORD,Callbacks callback)
e.g
cometchat.login("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"}
You can also login to CometChat by using your UserID.
The syntax of this login method is as follows:
login(String USER_ID,Callbacks callback)
e.g
cometchat.login("1245", new Callbacks() {
@Override
public void successCallback(JSONObject success) {}
@Override
public void failCallback(JSONObject fail) {}
});
The success response will be same as of above.
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!