ANDROID SDK

Desk360 is an Android SDK that helps you embed customer support in your mobile Android apps with ease.‌

Features

The Desk360 SDK lets customers do any of the following:‌

  • Create new support tickets

  • View and comment on existing tickets

  • Interactively communicate with related support teams.

Installation

Gradle

To integrate Desk360 into your Android project, add the code below to your project level build.gradlle

allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}

Add the dependency

dependencies {
implementation 'com.github.Teknasyon-Teknoloji:desk360-android-sdk:0.6.14'
}

Or Maven

Step 1. Add the JitPack repository to your build file

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

Step 2. Add the dependency

<dependency>
<groupId>com.github.Teknasyon-Teknoloji</groupId>
<artifactId>desk360-android-sdk</artifactId>
<version>Tag</version>
</dependency>

Add to your AndroidManifest.xml

<application
...
<activity
android:name="com.teknasyon.desk360.view.activity.Desk360BaseActivity"
android:windowSoftInputMode="stateHidden|adjustResize"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
</application>

Network Security Config

Create network_security_config.xml and add it to your application.

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">teknasyon.desk360.com</domain>
</domain-config>
</network-security-config>

Add reference to new created network security config in application tag in your manifest file

<application
...
android:networkSecurityConfig="@xml/network_security_config"
</application>

or you can just add this line to your application

<application
...
android:usesCleartextTraffic="true"
</application>

ProGuard

If you are using ProGuard you must add this rules to avoid further compile issues.

-keep class com.teknasyon.desk360.model.** { *; }
-keepnames class com.teknasyon.desk360.model.** { *; }
-keep class com.teknasyon.desk360.modelv2.** { *; }
-keepnames class com.teknasyon.desk360.modelv2.** { *; }

Usage

Desk360 helper method returns an intent to open Desk360 screen. Target ID is the ID of a ticket opened with a notification. If there is no intent to open a ticket page directly this parameter can be passed blank. Push token can be fetched from Firebase Messaging SDK. If notification integration won’t be used, this parameter can be left blank.

Start Desk360

val intent = Desk360Constants.initDesk360(
context= context,
token= pushToken,
targetId= targetId,
appVersion= BuildConfig.APP_VERSION,
deviceToken= uuid,
appKey= BuildConfig.DESK360_KEY,
appLanguage= “en”,
isTest= false
)
startActivity(intent)

Parameters

Description

token

firebase token

targetId

ticket ID from Firebase message body

appKey

desk360 API Key will provided when you get the license

appVersion

version number of your application

deviceToken

your Android device ID

appLanguage

Code for SDK languages: "en" , "fr" , "tr"

isTest

boolean flag for test or prod API

Using Optional Notification System

GetFirebase Token

FirebaseInstanceId.getInstance().instanceId
.addOnCompleteListener { task ->
if (task.isSuccessful && task.result != null) {
val token = task.result!!.token
}
}

Parse "targetId" from Firebase Notification Body (Firebase Notification Service)

When your application is on foreground onMessageReceived will handle notification body.

override fun onMessageReceived(remoteMessage: RemoteMessage) {
super.onMessageReceived(remoteMessage)
val hermes = remoteMessage.data["hermes"]
hermes?.let {
val targetId = Desk360Constants.getTicketId(hermes)
}

Handling "targetId"

If target_id is not null you must open Desk360SplashActivity if not you must open your starting activity

Example (In your firebaseMessagingService class) :
val pendingIntent: PendingIntent?
pendingIntent = targetId?.let { targetId ->
val intent = Desk360Constants.initDesk360(
context = this,
token = "your firebase token",
targetId = "targetId from notification body",
appVersion = "app version",
deviceToken = "your Android device id",
appKey = "desk360 api key",
appLanguage = "your selected ISO 639-1 Code for language"
isTest: "boolean flag for test or prod api")
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT)
} ?: run {
PendingIntent.getActivity(this, 0, Intent(this, YourStartingActivity::class.java), PendingIntent.FLAG_ONE_SHOT)
}

Parse "targetId" from Firebase Notification Body (Starting Activity)

When your application is killed the notification body will be in your starting activity's extra.

val bundle = intent.extras
bundle?.let {
val hermes = bundle?.getString("hermes")
hermes?.let {
val targetId = Desk360Constants.getTicketId(hermes)
}
}

Open Desk360 without Notification Service

If your app will not use notification then you must set token "and for targetId"

val intent = Desk360Constants.initDesk360(
context = this,
token = "your firebase push token",
targetId = "targetId from notification body",
appVersion = "app version",
deviceToken = "your Android device id",
appKey = "desk360 api key",
appLanguage = "your selected ISO 639-1 Code for language",
isTest: "boolean flag for test or prod api")
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP )
startActivity(intent)
finish()

Language

If you don't want to use custom language then you must set to "", desk360 SDK will use your Android device language

Customize Desk360 Theme

You should use Desk360 dashboard for custom config. For further information, please contact us via [email protected]