Get Started
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.
build.gradle (project)
allprojects {
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:
build.gradle (:app)
dependencies {
implementation 'com.github.taptalk-io:taptalk.io-omnichannel-android:2.1.0'
}
Note: In the app build.gradle file, make sure that your project is using supported Java 8 language features under the
android
tag like belowbuild.gradle (:app)
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility 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.Java
Kotlin
Application.java
TapTalkLive.init(
CONTEXT,
APP_KEY_SECRET,
CLIENT_APP_ICON,
CLIENT_APP_NAME,
new TapTalkLiveListener() {
@Override
public void onInitializationCompleted() {
// Handle initialization success here
}
@Override
public void onInitializationFailed(TTLErrorModel error) {
// Handle initialization failure here
}
}
);
Application.kt
TapTalkLive.init(
CONTEXT,
APP_KEY_SECRET,
CLIENT_APP_ICON,
CLIENT_APP_NAME,
object : TapTalkLiveListener() {
override fun onInitializationCompleted() {
// Handle initialization success here
}
override fun onInitializationFailed(error: TTLErrorModel?) {
// Handle initialization failure here
}
}
)
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 callbacksNote: A more complete implementation of TapTalkLiveListener callbacks can be seen in the Event Listeners page.
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
<application
android:name=".YourApplication"
...>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
If your project already has defined paths, make sure the following paths exist in your paths xml file:
your_file_paths.xml
<paths>
<files-path name="YourFilesPath" path="." />
<external-path name="YourExternalPath" path="." />
<cache-path name="YourCachePath" path="."/>
<external-files-path name="YourExternalFilesPath" path="."/>
<external-cache-path name="YourExternalCachePath" path="."/>
</paths>
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.Java
Kotlin
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
<application
android:name=".YourApplication"
...>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="GOOGLE_PLACES_API_KEY" />
</application>
To enable some features, such as sending link preview in messages, please enable
usesCleartextTraffic
in AndroidManifest.xml file.AndroidManifest.xml
<application
android:name=".YourApplication"
...
android:usesCleartextTraffic="true">
...
</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.Java
Kotlin
YourActivity.java
TapTalkLive.openTapTalkLiveView(YourActivity.this);
YourActivity.kt
TapTalkLive.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.You may optionally attach TapTalk Omnichannel's chat list fragment to your own activity. To obtain the chat list fragment instance, use the
getCaseListFragment
method. Java
Kotlin
YourActivity.java
TTLCaseListFragment fragment = TapTalkLive.getCaseListFragment();
YourActivity.kt
val fragment = TapTalkLive.getCaseListFragment()
getCaseListFragment
will return a TTLCaseListFragment
instance.Last modified 1d ago