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.

Guides    API Explorer

Android Custom UI Quickstart

This guide will get you started with the Applozic Android SDK. On completion, you will be able to successfully send a message.

This guide will get you started with the Applozic Android SDK. On completion, you will be able to successfully send a message.

You will be using the Custom UI APIs present in the Applozic Android SDK. Using custom UI APIs, you can implement your designs with your custom workflows.

To successfully send a message, all you need to do is:

  1. Install the SDK.
  2. Create and authenticate a user.
  3. Send a message from your newly authenticated user to an existing one.

Pre-requisites

To work with the Applozic SDK you will need to have an Application-ID. You can get that in Applozic Dashboard by creating an account(it’s free to try out). Create an account in Applozic and then get the application-id here.

Now that you have your application-id, follow these three simple steps to successfully send a message.

1. Installation

To install the app, you just need to follow these steps.

Add the following dependency in your app-level (Not the project-level) build.gradle file:

dependencies {
   //your other dependencies go here
    implementation 'com.applozic.communication.message:mobicomkit:5.97.1'
}

If you wish to go further than just sending a message, refer to our
detailed installation guide here.

2. Authentication

Authenticating a user means registering it on the Applozic server. To do so you need to first initialize the Applozic SDK using the application-id (see pre-requisites). Then you can create a user and register it.

To initialize the SDK use the following code:

Applozic.init(context, "AppID");
Applozic.init(context, "AppID")

Replace the AppID with the one you acquired.

Then create and register a user:

User user = new User();
user.setUserId(userId); //required
//user.setDisplayName(displayName); //optional
//user.setEmail(email); //optional
user.setAuthenticationTypeId(User.AuthenticationType.APPLOZIC.getValue()); //optional
user.setPassword(password); //optional
//user.setImageLink(""); //optional
 
Applozic.connectUser(context, user, new AlLoginHandler() {
@Override
public void onSuccess(RegistrationResponse registrationResponse, Context context) {
// After successful registration with Applozic server the callback will come here
}
 
@Override
public void onFailure(RegistrationResponse registrationResponse, Exception exception) {
// If any failure in registration the callback will come here
}
});
val user = User()
user.userId = <USER_ID> // userId it can be any unique user identifier NOTE : +,*,? are not allowed chars in userId.
user.displayName = <DISPLAY_NAME> // displayName is the name of the user which will be shown in chat message
user.authenticationTypeId = User.AuthenticationType.APPLOZIC.getValue() //User.AuthenticationType.APPLOZIC.getValue() for password verification from Applozic server and User.AuthenticationType.CLIENT.getValue() for access Token verification from your server set access token as password
user.password = "" // Optional, Pass the password
user.imageLink = <IMAGE_URL_LINK> // Optional, If you have public image URL of user you can pass here

Applozic.connectUser(context, user, object : AlLoginHandler {
      override fun onSuccess(registrationResponse: RegistrationResponse?, context: Context?) {
          // After successful registration with Applozic server the callback will come here
      }

      override fun onFailure(
          registrationResponse: RegistrationResponse?,
          exception: Exception?
       ) {
          // If any failure in registration the callback  will come here
           if (registrationResponse != null) {
               Log.i("ApplozicLogin", "Login as been failed:" + registrationResponse.message)
           } else if (exception != null) {
               Log.i("ApplozicLogin", "Login as been failed due to exception:" + exception.localizedMessage)
           }
       }
 })

Note: When creating the user, the user-id is the only required field. It can be any unique string.
Note: If the user is already registered, the Applozic.connectUser() method logs in the user.

For detailed instructions on Authentication with other helper methods, refer to this.

3) Send Message

A message can be sent to any user of your app. To create another user go to the dashboard and create a user. Be sure to note down the userId.

Now you can send a message to a user by using the MessageBuilder class using the code:

new MessageBuilder(context).setMessage("This is the message text.").setTo("userId").send();
new MessageBuilder(context)
  .setMessage("This is the message text.")
  .setTo(userId)
  .send();

The userId is the userId of the user you just created in the dashboard. This user is called a Contact in the context of the currently logged-in user.
Refer to this documentation for more information about contacts.

To test if your message was successfully sent, add a MediaUploadProgressHandler to the send() method.
This handler is usually used for attachments, and we can use its onSent() callback here.
*Replace the above message builder code with:

new MessageBuilder(getApplicationContext()).setMessage("This is the message text.").setTo(userId).send(new MediaUploadProgressHandler() {
 @Override
 public void onUploadStarted(ApplozicException e, String oldMessageKey) {
    //not required for this quickstart guide
 }
 
 @Override
 public void onProgressUpdate(int percentage, ApplozicException e, String                          oldMessageKey) {
    //not required for this quickstart guide
 }
 
 @Override
 public void onCancelled(ApplozicException e, String oldMessageKey) {
    //not required for this quickstart guide
 }
 
 @Override
 public void onCompleted(ApplozicException e, String oldMessageKey) {
    //not required for this quickstart guide
 }
 
 @Override
 public void onSent(Message message, String oldMessageKey) {
    //on callback recieved from server
    Log.d(“MessageTest”, “Message Sent Sucessfully”);
 }
});
MessageBuilder(context)
                .setMessage("This is the message text.")
                .setTo(userId)
                .send(object : MediaUploadProgressHandler {
                    override fun onUploadStarted(e: ApplozicException?, oldMessageKey: String?) {
                        //not required for this quickstart guide
                    }

                    override fun onProgressUpdate(percentage: Int, e: ApplozicException?, oldMessageKey: String?) {
                        //not required for this quickstart guide
                    }

                    override fun onCancelled(e: ApplozicException?, oldMessageKey: String?) {
                        //not required for this quickstart guide

                    }

                    override fun onCompleted(e: ApplozicException?, oldMessageKey: String?) {
                        //not required for this quickstart guide
                    }

                    override fun onSent(message: Message, oldMessageKey: String?) {
                        //The message containing the attachment has been sent to the server.
                        //on callback recieved from server
                        Log.d(“MessageTest”, “Message Sent Sucessfully”);
                    }
                })

After the message is successfully sent, the log will show “Message Sent Successfully” in the “MessageTest” tag.

For more information about the Message API refer to this [https://docs.applozic.com/docs/android-chat-message-api].

Congratulations, you have successfully sent a message. If you want to explore the SDK further refer to the following links:

  • For fetching a list of conversations: Conversation section.
  • To get Real-time updates on a message received, read or if the other user is typing: Real-time updates section. In this section, we have also explained how to send typing status if the logged in user is typing. To receive app notifications Push notification setup is required.
  • For creating a group, adding users and updating the group details check out Groups section.

Sample App

You can check out the sample app where we have used Android Custom UI APIs to show some of the SDK features.

👍

Support

If you have any doubts or you are facing any issue in integration then you can check out our support page for help.

Updated 3 months ago


Android Custom UI Quickstart


This guide will get you started with the Applozic Android SDK. On completion, you will be able to successfully send a message.

Suggested Edits are limited on API Reference Pages

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