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.

You first need to login to your website using SDK. Using SDK you can login by 3 ways

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

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

    The parameters description is as follows:
    1. siteurl : This is site url where CometChat has installed, for example, http://www.yoursite.com/cometchat/
    2. username : username is mandatory, which can not be empty.
    3. 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(siteurl,userid,successCallback,failCallback);

    The parameters description is as follows:
    1. siteurl : This is site url where CometChat has installed, for example, http://www.yoursite.com/cometchat/
    2. userid : userid is mandatory, which can not be empty.

    The success response will be same as above

  • Login as a guest user
  • 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 :

    Customui.guestLogin(siteurl,guestname,successCallback,failCallback);

    1. siteurl :This is site url where CometChat has installed, for example, http://www.yoursite.com/cometchat/
    2. guestname : userid is mandatory, which can not be empty.

    The success response will be as follows:

    {"message": "Login successful" }

    Here the id is the identification number given to the guest.

    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!