Before you get started: Make sure you have created a channel in OneTalk dashboard and obtain the APP_KEY_SECRET.
To start, open your Android project and add the following repositories to your top-level build.gradle file.
Project build.gradleallprojects {repositories {google()jcenter()maven { url 'https://jitpack.io' }maven { url "https://s3.amazonaws.com/repo.commonsware.com" }}}
Then add the following dependency to your app-level build.gradle:
app module build.gradledependencies {implementation 'com.github.taptalk-io:taptalk.io-omnichannel-android:1.0.6'}
Note: In the app build.gradle file, make sure that your project is using supported Java 8 language features under the android
tag like below
app module build.gradleandroid {...​compileOptions {sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8}}
In order to use TapTalkLive SDK, you must first initialize a TapTalkLive instance by passing the CONTEXT
, APP_KEY_SECRET
, CLIENT_APP_ICON
, and CLIENT_APP_NAME
assigned to your application to the init
method as a parameter. Generally, initialization is implemented in the Application class in your project.
Application.javaTapTalkLive.init(CONTEXT,APP_KEY_SECRET,CLIENT_APP_ICON,CLIENT_APP_NAME,new TapTalkLiveListener() {@Overridepublic void onInitializationCompleted() {super.onInitializationCompleted();}​@Overridepublic void onCloseButtonInCreateCaseFormTapped() {super.onCloseButtonInCreateCaseFormTapped();}​@Overridepublic void onCloseButtonInCaseListTapped() {super.onCloseButtonInCaseListTapped();}});
Application.ktTapTalkLive.init(CONTEXT,APP_KEY_SECRET,CLIENT_APP_ICON,CLIENT_APP_NAME,object : TapTalkLiveListener() {override fun onInitializationCompleted() {super.onInitializationCompleted()}​override fun onCloseButtonInCreateCaseFormTapped() {super.onCloseButtonInCreateCaseFormTapped()}​override fun onCloseButtonInCaseListTapped() {super.onCloseButtonInCaseListTapped()}})
CONTEXT
(Context) application context
APP_KEY_SECRET
: (String) application key Secret
CLIENT_APP_ICON
: (int) drawable resource ID of your application's icon
CLIENT_APP_NAME
: (String) your application name
tapTalkLiveListener
: (TapTalkLiveListener) an interface to detect TapTalkLive Android SDK's delegates and callbacks
To enable file transfer through chat messages, you need to define FileProvider in your application's AndroidManifest.xml file, under the <application>
tag.
AndroidManifest.xml<applicationandroid:name=".YourApplication"...>​<providerandroid:name="android.support.v4.content.FileProvider"android:authorities="${applicationId}.fileprovider"android:exported="false"android:grantUriPermissions="true"><meta-dataandroid:name="android.support.FILE_PROVIDER_PATHS"android:resource="@xml/file_paths" /></provider>​</application>
To enable location search result preview while sending location message, a Google Places API Key is required. To obtain the API key for your application, you can check the documentation provided by Google. To initialize, insert your obtained key using the initializeGooglePlacesApiKey()
method after TapTalkLive SDK has completed its initialization.
TapTalkLive.initializeGooglePlacesApiKey(GOOGLE_MAPS_API_KEY);
TapTalkLive.initializeGooglePlacesApiKey(GOOGLE_MAPS_API_KEY)
Your key also needs to be defined in your application's AndroidManifest.xml file, under the <application>
tag.
AndroidManifest.xml<applicationandroid:name=".YourApplication"...>​<meta-dataandroid:name="com.google.android.geo.API_KEY"android:value="GOOGLE_PLACES_API_KEY" />​</application>
To open TapTalkLive's view UI for your application, you can use the openTapTalkLiveView
method from the TapTalkLive class. This will open an activity containing a chat room list for your user, and will open a Create Case Form activity on top if the user is new or do not have any existing case.
YourActivity.javaTapTalkLive.openTapTalkLiveView(YourActivity.this);
YourActivity.javaTapTalkLive.openTapTalkLiveView(this@YourActivity)
openTapTalkLiveView
will return true
if opening the view is successful, and will return false
if it fails due to incomplete initialization. TapTalkLive initialization might not be completed if the device is not connected to internet or an incorrect APP_KEY_SECRET
parameter was provided.