Chat APIs and In-app Messaging SDKs for Developers

Applozic provides Chat APIs and In-app Messaging SDKs for Android, iOS and Web apps to power cross-device, multi-platform rich messaging.
Find comprehensive guides and platform-specific Chat API documentation to get started with In-app Messaging.

Get Started    

Authentication

Web plugin authentication guide

Pre-built customizable chat UI

Login/Register user

Login or Register with userId and username.

Applozic creates a new user if the user doesn't exists.

userId is the unique identifier for a user, it can be anything like email, phone number or uuid from your database.

Copy the following script just below the code added from Installation.

<script type="text/javascript">
  window.applozic.init({
    appId: <App_ID>,      //Get your App ID from https://console.applozic.com/settings/install
    userId: userId,                     //Logged in user's id, a unique identifier for user
  accessToken: '',                              //Enter password here for the userId passed above, read this if you want to add additional security by verifying password from your server https://www.applozic.com/docs/configuration.html#access-token-url
    userName: username,                 //User's display name
    imageLink : '',                     //User's profile picture url
    email : '',                         //optional
    contactNumber: '',                  //optional, pass with internationl code eg: +13109097458
    desktopNotification: true,
    source: '1',                          // optional, WEB(1),DESKTOP_BROWSER(5), MOBILE_BROWSER(6)
    notificationIconLink: 'https://www.applozic.com/favicon.ico',    //Icon to show in desktop notification, replace with your icon
    authenticationTypeId: 1,          //1 for password verification from Applozic server and 0 for access Token verification from your server
    locShare: true,                     //to enable location sharing
    googleApiKey: "AIzaSyDKfWHzu9X7Z2hByeW4RRFJrD9SizOzZt4",   // your project google api key
        unreadCountOnchatLauncher: true, // if true, will show unread count on chat widget
    googleMapScriptLoaded : false,   // true if your app already loaded google maps script
    mapStaticAPIkey: "AIzaSyCWRScTDtbt8tlXDr6hiceCsU83aS2UuZw",
    autoTypeSearchEnabled : true,     // set to false if you don't want to allow sending message to user who is not in the contact list
    loadOwnContacts : false, //set to true if you want to populate your own contact list (see Step 4 for reference)
    olStatus: false,         //set to true for displaying a green dot in chat screen for users who are online
    onInit : function(response,data) {
       if (response === "success") {
          // login successful, perform your actions if any, for example: load contacts, getting unread message count, etc
       } else {
          // error in user login/register (you can hide chat button or refresh page)
       }
   },
   contactDisplayName: function(otherUserId) {
         //return the display name of the user from your application code based on userId.
         return "";
   },
   contactDisplayImage: function(otherUserId) {
         //return the display image url of the user from your application code based on userId.
         return "";
   },
   onTabClicked: function(response) {
         // write your logic to execute task on tab load
         //   object response =  {
         //    tabId : userId or groupId,
         //    isGroup : 'tab is group or not'
         //  }
   }
  });
</script>

Build your UI from scratch

Login

userId : "unique identifier for a user"
applicationId : <Your_App_ID>
appVersionCode : Don't change this code. It is used by the server to identify the version running on the client.

var events = {
    'onConnectFailed': function(resp) {},
    'onConnect': function(resp) {},
    'onMessageDelivered': function(resp) {},
    'onMessageRead': function(resp) {
      //called when a message is read by the receiver 
    },
    'onMessageDeleted': function(resp) {},
    'onConversationDeleted': function(resp) {},
    'onUserConnect': function(resp) {},
    'onUserDisconnect': function(resp) {},
    'onConversationReadFromOtherSource': function(resp) {},
    'onConversationRead': function(resp) {
      //called when the conversation thread is read by the receiver
    },
    'onMessageReceived': function(resp) {
      //called when a new message is received
    },
    'onMessageSentUpdate': function(resp) {},
    'onMessageSent': function(resp) {
      //called when the message is sent
    },
    'onUserBlocked': function(resp) {},
    'onUserUnblocked': function(resp) {},
    'onUserActivated': function(resp) {},
    'onUserDeactivated': function(resp) {},
    'connectToSocket': function(resp) {},
    'onMessage': function(resp) { 
      
      console.log(resp); 
      
      //called when the websocket receive the data
    
    },
    'onTypingStatus': function(resp) {}
};
      
Applozic.ALApiService.login(
  {
    data: {
      baseUrl: 'https://apps.applozic.com',
      alUser:
      {
        userId: userId, //Logged in user's id, a unique identifier for user
        password: '',//Enter password here for the userId passed above, read this if you want to add additional security by verifying password from your server https://www.applozic.com/docs/configuration.html#access-token-url
        imageLink: '', //User's profile picture url
        email: '', //optional
        contactNumber: '', //optional, pass with internationl code eg: +13109097458
        appVersionCode: 111,
        applicationId: '<App_ID>', //Get your App ID from [Applozic Dashboard](https://console.applozic.com/settings/install)
      }
    },
    success: function(response) {
      console.log(response);
      //Get your App ID from [Applozic Dashboard](https://console.applozic.com/settings/install)
      window.Applozic.ALSocket.init(<App_ID>, response, events);
      // This method initializes socket connection 
    },
    error: function(error) {
        console.log(error);
    }
  }
);

Sample Response

{
    "token": "4010a573-6b61-46fc-a5d7-21b734bb9a18",
    "userId": "debug4",
    "clientId": "paho587855142915212",
    "displayName": "debug4",
    "deviceKey": "953d00ca-f98d-49de-9697-b3a1dc807561",
    "timeZoneOffset": "19800000",
    "websocketUrl": "https://apps-test.applozic.com",
    "fileBaseUrl": "https://mobi-com-alpha.appspot.com",
    "betaPackage": false,
    "websocketIdleTimeLimit": 90,
    "deactivated": false,
    "connectedClientCount": 0,
    "totalUnreadCount": 16,
    "statusMessage": "Hi there!",
    "encryptionType": 2,
    "roleType": 3,
    "metadata": {}
}

Adding additional fields in User

If you need to add some additional fields to a User object that is not a property of the existing User object then you can set the additional fields in the metadata of the User.
For eg. You need to add some fields like Department, Designation, Team etc to a User, then you can use the User metadata.

Applozic.ALApiService.updateUserDetail({
    data:
        {
            email: "user email",
            displayName: "user display name",
            imageLink: "User profile image url",
            statusMessage: "status Message",
            metadata:{
               "key1":"value1",
               "key2":"value2",
               "key3":"value3" 
               }
          },
    success: function (response{ console.log(response); },
    error: function () { } });

Updated 3 months ago



Authentication


Web plugin authentication guide

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.