Integrate our SDK into your app
Application class
Pass the application context to the `AssistSession` in the `onCreate` of the base application.
class TestApplication: Application() {
override fun onCreate() {
super.onCreate()
//Provide the application context to the SDK
AssistSession.INSTANCE.setContext(this)
}
}
MainActivity class
Start the `AssistSession` in the activity and set up all the necessary lifecycle methods as shown below.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
AssistSession.INSTANCE.onCreate(this, TestCallbacks())
if (!AssistSession.INSTANCE.isSessionAlive()) {
AssistSession.INSTANCE
//Required, Set the SDK Token to be used for validation
.setAuthToken(sdkToken)
//Optional, Set the customer details
.setCustomerDetails("John Doe","johndoe@example.com")
//Optional, Set whether a Bubble/FloatingHead should be shown when app is in background
.enableFloatingHead(true)
//Optional, Set the foreground service notification to be shown during a session
.setKeepAliveNotification(notification)
//Optional, Set default quality to start the session with
.setQuality(Constants.ColorQualityFactors.QUALITYAUTO)
//Optional, Set whether the session should be started immediately,
//Default is true, if set to false then session needs to be started in the callbacks
.shareScreenOnStart(true)
//Optional, Set whether remote control (if supported for the device) should be start as soon as session starts,
//Default is true, if set to false then remote control will need to be started in the callbacks
.startRemoteControlOnStart(true)
//Optional, Set whether the addon used for Remote Control should be downloaded on session start (assuming it's available in the playstore)
.downloadAddonOnStart(true)
//Required, Start the session by passing the session key, the activity to open when notification(or bubble) is clicked & the icon to be used in notification(and bubble)
.start(sessionKey, this::class.java, R.drawable.ic_launcher_foreground)
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
data?.let {
AssistSession.INSTANCE.onActivityResult(requestCode, resultCode, it)
}
}
override fun onStop() {
super.onStop()
AssistSession.INSTANCE.onStop()
}
override fun onResume() {
super.onResume()
AssistSession.INSTANCE.onResume()
}
override fun onBackPressed() {
//Handle what happens when back button is pressed
if (!AssistSession.INSTANCE.isSessionAlive()) {
super.onBackPressed()
} else {
AssistSession.INSTANCE.onCustomerEndSession()
}
}
}