Login/Logout

To add Login support in your application,

Include CustomUI.js in your index.html file to access the Custom UI functionality in your Cordova app

All the method calls will invoke their respective callback blocks as defined below.

Customui.setUrl(api,successCallback,failCallback);

The parameters description is as follows:
1. api : API-Key is mandatory, which can not be empty.

Login to CometChat

To start with using SDK functionality, you first need to login to your website using SDK. Using SDK you can login by 2 ways

  • Using username & password
  • The syntax for the login using username and password is as follows :

    Customui.loginUsername(username,password,successCallback,failCallback);

    The parameters description is as follows:
    1. username : username is mandatory, which can not be empty.
    2. password : Password is mandatory, which can not be empty.

    If you have logged in successfully the successCallback will be fired, containing the following response :

    {"message": "Login successful"}
  • Using the UserID
  • Syntax for login using the userID is :

    Customui.loginUserid(userid,successCallback,failCallback);

    The parameters description is as follows:
    1. userid : userid is mandatory, which can not be empty.

    The success response will be same as above

    Logout from CometChat

    Calling this function will end the current session and clears user data.
    The syntax is as follows :

    Customui.logout();

    Not finding what you need?

    The CometChat team is here to help!