Install Brand Messenger Android SDK
Install the Brand Messenger Android SDK into your project
Prerequisites
Get your Company Key and Application ID
Contact Khoros Support for your Company Key, Application ID, and access to the Brand Messenger Android SDK.
Requirements
- Latest android studio
- From version 1.3.0, the SDK requires application's compileSdkVersion and targetSdkVersion to be 31 or higher
- The minimum android SDK version supported is 19.
Installation
The Brand Messenger Android SDK is distributed via a jitpact.io private repository. Follow the instructions on JitPack Auth to access private repositories and add the following data to your project.
Add JitPack repository to the end of the root build.gradle file:
allprojects {
repositories {
...
maven {
url "https://jitpack.io"
credentials { username authToken }
}
}
}
Add Brand Messenger to the module build.gradle:
dependencies {
implementation 'com.github.lithiumtech.android-brandmessenger-sdk-dist:brandmessengercore:<version>'
implementation 'com.github.lithiumtech.android-brandmessenger-sdk-dist:brandmessengerui:<version>'
}
Pre-built customizable chat UI
This section will guide you in using our pre-built chat UI in your Android app.
- Add your Brand Messenger Company Key and Application ID to your manifest. Contact Khoros Support for the Company Key and Application ID:
<meta-data android:name="com.brandmessenger.company.key"
android:value="<YOUR_BRAND_MESSENGER_COMPANY_KEY>" />
<meta-data android:name="com.brandmessenger.application.key"
android:value="<YOUR_BRAND_MESSENGER_APP_ID>" />
-
For enabling push notifications, you must have a Firebase account. Sign up to Firebase console and create your application with app package name
and generate a push notification Google JSON service file. Then, place the file in your application under the app folder. -
Contact Khoros Support with the GCM/FCM server key to update it on the push notification server.
-
Add the following in Gradle Android target:
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ECLIPSE_.SF'
exclude 'META-INF/ECLIPSE_.RSA'
}
}
AndroidManifest
Add the following Permissions, Activities, Services, and Receivers in your androidmanifest.xml:
Add meta-data, Activities within application Tag
If using
tools:node="replace"
tag for any component, metadata or permissions, make sure to define the tag within your</manifest>
tag as:xmlns:tools="http://schemas.android.com/tools"
Add the metadata as shown below:
<!-- Brand Messenger Company Key -->
<meta-data android:name="com.brandmessenger.company.key"
android:value="<YOUR_BRAND_MESSENGER_COMPANY_KEY>" />
<!-- Brand Messenger App ID -->
<meta-data android:name="com.brandmessenger.application.key"
android:value="<YOUR_BRAND_MESSENGER_APP_ID" />
<!-- Launcher white Icon -->
<meta-data android:name="com.brandmessenger.core.ui.notification.smallIcon"
android:resource="YOUR_LAUNCHER_SMALL_ICON" />
<!-- Notification color -->
<meta-data android:name="com.brandmessenger.core.ui.notification.color"
android:resource="YOUR_NOTIFICATION_COLOR_RESOURCE" />
<!-- NOTE: Do NOT change this, it should remain same i.e 'com.package.name' -->
<meta-data android:name="com.package.name"
android:value="${applicationId}" />
Add the Activity as shown below:
<activity android:name="com.brandmessenger.core.ui.conversation.activity.ConversationActivity"
android:configChanges="keyboardHidden|screenSize|locale|smallestScreenSize|screenLayout|orientation"
android:label="@string/app_name"
android:launchMode="singleTask"
android:parentActivityName=".MainActivity"
android:theme="@style/KBMTheme"
tools:node="replace">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
Replace the parent activity with your app's parent activity.
Your final AndroidManifest file should look something like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mobicomkit.sample"
android:versionCode="1"
android:versionName="1.0">
<application
android:name=".MainApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.brandmessenger.core.ui.conversation.activity.ConversationActivity"
android:configChanges="keyboardHidden|screenSize|locale|smallestScreenSize|screenLayout|orientation"
android:label="@string/app_name"
android:launchMode="singleTask"
android:parentActivityName=".MainActivity"
android:theme="@style/KBMTheme"
tools:node="replace">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<!-- Brand Messenger Company Key -->
<meta-data android:name="com.brandmessenger.company.key"
android:value="<YOUR_BRAND_MESSENGER_COMPANY_KEY>" />
<!-- Brand Messenger App ID -->
<meta-data android:name="com.brandmessenger.application.key"
android:value="<YOUR_BRAND_MESSENGER_APP_ID" />
<!-- Launcher white Icon -->
<meta-data android:name="com.brandmessenger.core.ui.notification.smallIcon"
android:resource="YOUR_LAUNCHER_SMALL_ICON" />
<!-- Notification color -->
<meta-data android:name="com.brandmessenger.core.ui.notification.color"
android:resource="YOUR_NOTIFICATION_COLOR_RESOURCE" />
<!-- NOTE: Do NOT change this, it should remain same i.e 'com.package.name' -->
<meta-data android:name="com.package.name"
android:value="${applicationId}" />
</manifest>
ProGuard Setup
Add the following if you are using ProGuard:
#keep json classes
-keepclassmembernames class * extends com.brandmessenger.commons.json.JsonMarker {
!static !transient <fields>;
}
-keepclassmembernames class * extends com.brandmessenger.commons.json.JsonParcelableMarker {
!static !transient <fields>;
}
-keep class com.brandmessenger.** {
!static !transient <fields>;
}
#GSON Config
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.examples.android.model.** { *; }
-keep class org.eclipse.paho.client.mqttv3.logging.JSR47Logger { *; }
-keep class android.support.** { *; }
-keep interface android.support.** { *; }
-dontwarn android.support.v4.**
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
-keep class com.google.gson.** { *; }
Below is the list of libraries used in the Brand Messenger SDK:
implementation 'de.hdodenhof:circleimageview:3.1.0' //for circular images
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'//for image cropping
implementation 'com.github.bumptech.glide:glide:4.12.0' //for loading images
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'//constraint layout
api 'androidx.appcompat:appcompat:1.3.0'
api "com.google.code.gson:gson:2.8.6" //JSON parsing library
api "com.google.firebase:firebase-messaging:22.0.0" //for FCM notification
api "com.google.android.gms:play-services-maps:17.0.1" //for google maps
api "com.google.android.gms:play-services-location:18.0.0" //for location services
Updated about 2 months ago