This website is no longer maintained. Please, visit documentation.indigitall.com to read our updated documentation.

Chat Android

quick integration guide

Index

What do you need for integration?

  • Android Studio
    • An Android device or emulator with Google Play services installed to run the app

Integration

This article shows the minimum development that must be done to start registering devices and being able to carry out the first push campaigns.

Adding the Chat dependencies

The first thing to do is open the app / build.gradle file. In the screenshot you can see where to find this app / build.gradle file.

AtenciĆ³n: It is the build.gradle file found in the app folder, NOT the root of the project.


Gradle build file

The library is available through the repository Maven Central . Maven is one of the most used library management tools in Android. To integrate the Chat of indigitall it is necessary to add the following dependencies:

  • The Android Support Library
  • The SocketIO-client library
  • Indigitall's Chat


android {
    compileSdkVersion 31
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 31
    }
}

repositories {
    mavenCentral()
}

dependencies {
    //implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.indigitall:android-chat:1.3.+'
    implementation 'io.socket:socket.io-client:0.8.3'
}

Initialize Chat

To initialize the Chat it is necessary to add the object com.indigitall.android.chat.Chat in the layout where the Chat will be displayed. We must add the following lines of code:

<com.indigitall.android.chat.Chat
        android:id="@+id/your_id"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:channelKey="your_channel_key"
        //opciones personalizadas
        app:externalKey="your_external_key"
        app:titleChat="your_title_chat"
        app:botName="your_bot_name"
        app:defaultUserName="your_user_name_default"
        app:messagePlaceholder="your_message_place_holder"
        app:openFileText="your_text_open_file"
        app:backgroundColor="your_background_color"
        app:backgroundBarColor="your_background_bar_color"
        app:primaryColor="your_primary_color"
        app:fullscreen="bool"
        app:defaultChatIconResource="your_chat_custom_icon"
        app:addContactTextButton="your_contact_text_button"
        app:contactAddedMessage="your_contact_added_message"
        app:infoContactIconsColor="your_info_contact_icons_color"
        app:infoContactTopBarTitle="your_info_contact_top_bar_title"
        app:chatAutoOpenTime="your_chat_auto_open_time_in_seconds"
        app:clearMessages="bool"
        app:welcomeEvent="your_welcome_event"
        />


  • id id of the object.
  • channelKey is an alphanumeric string that identifies your indigitall project.

The following fields are custom. If they are not added, the Chat will show the default values.

  • your_external_key is a string that identifies each device.
  • titleChat It is a string with the title that you want to be shown in the chat.
  • botName is a string with the name of the bot that will be displayed above the bubble on the left side.
  • defaultUserName It is a string with the default name that the user will have and will be displayed above the user's bubble.
  • messagePlaceholder It is a string with the message that is displayed in the text field where it must be written.
  • openFileText It is a string with the text that will be displayed in the case a file has to be downloaded.
  • backgroundColor is a string with the chat background color in hexadecimal or object color.
  • backgroundBarColor is a string with the background color of the upper and lower bars in hexadecimal or object color.
  • primaryColor is a string with the main color of the chat, buttons and floating icon in hexadecimal or object color.
  • fullscreen is a boolean where you indicate if you want the chat to occupy the entire screen (true) or have a certain margin of the device (false).
  • defaultChatIconResource is a reference with the icon resource taht show on the chat main icon.
  • addContactTextButton is a string with the message text to add a contact.
  • contactAddedMessage is a string with the message when you added a new contact.
  • infoContactIconsColor is a string with the color of the icons of info contact view
  • infoContactTopBarTitle is a string top bar title of info contact view.
  • chatAutoOpenTime is an integer that indicates the seconds for the chat to open automatically. If no chatAutoOpenTime is specified, such as if you press the bubble before the specified time expires, the chat can be opened manually.
  • clearMessages is a boolean that indicate if you want to delete or clear all messages from session storage every time you open the chat
  • welcomeEvent is a string to define the welcome message one time you open the chat

To verify that the integration was successful, do the following:

To be able to perform actions when the Chat is shown or hidden, event handlers or listeners can be implemented. To do this add the following code:


class YourActivity: ChatListener{
  ...
  override fun onChatHidden() {
        //Do something
    }

    override fun onChatShown() {
        //Do something
    }
}


Functionalities

You can check if the welcome event has been fired with this method:

val indigitallChat = findViewById<Chat>(R.id.chat)

val isEmitted = indigitallChat.isWelcomeEmitted();


If you want to send a message custom you can use this method:

val indigitallChat = findViewById<Chat>(R.id.chat)

indigitallChat.setCustomEvent("Your_event");


You can also control the action of deleting messages with this method:

val indigitallChat = findViewById<Chat>(R.id.chat)

indigitallChat.clearAllMessages()


Changelog

[1.4.1] - 03/2022

Fixes

  • Upload socket-io-client lib

[1.4.0] - 03/2022

Added

  • Welcome event
  • Clean messages

[1.3.0] - 01/2022

Added

  • Interactive Field
  • Automatically open chat option

[1.2.0] - 11/2021

Added

  • Show info contact and location option

[1.1.0] - 06/2021

Added

  • Added template with buttons and pdf

[1.0.1] - 01/2021

Added

  • Unity test

[1.0.0] - 11/2020

Added

  • Init


Resources

Start automating your communications thanks to our administration API