QuickStart

Prerequisites

To use the Messaging SDK, the following are required:

  • ContactAtOnce! account with messaging enabled
  • Embeddable library for AAR: Binary distribution of an Android Library Project
  • Installers: Gradle

Note: For information on supported operating systems and devices, refer to ContactAtOnce Mobile SDK System Requirements and Language Guide.

Step 1: Download and unzip the SDK

Follow the steps below to download and unzip the

  1. Download the latest Messaging SDK from the following link: SDK Repository.
  2. Extract the ZIP file to a folder on your computer.

The downloaded package should contain a folder named “android-Messaging-SDK”. It contains the sdk and a sample app.

Step 2: Configure project settings to connect Messaging SDK

Follow the steps below to configure the project settings to connect to the SDK.

  1. Copy the messaging-sdk folder to your project folder.
  2. Add the following lines to the build.gradle of your project’s repositories section :
maven {

  url "../messaging-sdk"

}
  1. Under the Dependencies section of the build.gradle of your app, add the following line:
compile ('com.contactatonce.messaging:sdk:1.0.0@aar') {transitive=true

Note: Because SDK versions must match between the app and the compiled library, make the compileSdkVersion and the targetSdkVersion equal to 25. In the dependencies section, make sure any versioned items are v25 as illustrated below:

dependencies {

  implementation 'com.android.support:design:25.4.0'

  compile 'com.android.support:appcompat-v7:25.4.0'

   . . .

}

Step 3: Code integration for basic deployment

  1. Add the following permission to your app’s AndroidManifest.xml file:
  • <uses-permission android:name="android.permission.INTERNET" />
  • <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Vibrate on new incoming msg (required if enabled) :

  • <uses-permission android:name="android.permission.VIBRATE"/>
  1. Add the following imports to your class imports section:
  • import com.contactatonce.messaging.IMessagingDelegate;
  • import com.contactatonce.messaging.InitMessagingCallBack;
  • import com.contactatonce.messaging.Messaging;
  • import com.contactatonce.messaging.MessagingConfig;
  • import com.contactatonce.messaging.MessagingConsumerProperties;
  • import com.contactatonce.messaging.infra.utils.BrandingWrapperUtil;
  1. Initialize the Messaging SDK

You can initialize the SDK in your Activity before showing the Messaging  Activity/Fragment, but it is recommended to initialize the SDK once, in your app’s Application class.

  1. Initialize the Messaging class with a instance of the MessagingConsumerProperties.
Override

public void onInitFailed(Exception e) {

}

 });

Show Conversation Screen

The SDK supports two operation modes:

  • Activity mode
  • Fragment mode

Activity Mode

To open conversation window in separate activity use the following. This will start a new conversation activity:

LivePerson.showConversation(getActivity(), brandId, authCode, consumerMessage);

Using this method, the SDK implements the controls on the action bar.

Fragment Mode

In fragment mode the SDK returns the conversation fragment to the caller that needs to be placed inside a container. Also, the caller is responsible for initializing the SDK and, if needed, implementing a toolbar or other indicators according to the provided SDK callbacks.

Note: Ensure that the init process finished successfully. These should be called from the onInitSucceed callback.

To open conversation window in a fragment: This returns a conversation fragment to be placed in a container in your activity:

LivePerson.getConversationFragment(brandId‎);

When using fragment mode, you should use the provided SDK callbacks in your app in order to implement functionalities such as menu items, action bar indications, agent name, and typing indicator.

Screen Orientation

In case of Fragment mode – set the desired orientation in your container Activity definition in AndroidManifest.xml

https://developer.android.com/guide/topics/manifest/activity-element.html#screen

In case of Activity mode – override in your application’s AndroidManifest.xml the ConversationActivity definition and set the desired screen orientation:

<activity
      android:name="com.liveperson.infra.messaging_ui.ConversationActivity"
      android:screenOrientation="your screen orientation" />