Skip to content

Configure KaleyraVideoSDK

Federico Marin edited this page Sep 4, 2024 · 8 revisions

Configure KaleyraVideo SDK

In order to configure the KaleyraVideoSDK correctly the following is required:

  • Setup a KaleyraVideo SDK configuration with appId
  • Specify an Environment (Production or Sandbox)
  • Specify the connection Region
  • Pass the configuration as a parameter to the configure method of KaleyraVideo instance.
val configuration = Configuration(
        appId = "mAppId_xxx",
        environment = Environment.Sandbox // Production
        region = Region.Europe // India, US
    )
KaleyraVideo.configure(configuration)

KaleyraVideoInitializer

It is strongly recommended to implement the abstract class KaleyraVideoInitializer in order to be notified whenever the KaleyraVideoSDk needs to be configured and connected. The class will be instantiated from within the SDK when needed.

The implementation of the abstract class KaleyraVideoInitializer is useful for some edge cases such as when the app has been killed from the operating system and then a notification (e.g. kaleyra video or chat notifications) is triggering the app restart but the KaleyraVideo.configure(configuration) and KaleyraVideo.connect(userId) { requestToken(loggedUserId) } methods have not been called.

To implement the abstract class KaleyraVideoInitializer please refer to the following snippet:

<!-- app manifest -->

<application>

	[...]

	<meta-data
		android:name="kaleyra_video_initializer"
		android:value="com.example.app.AppKaleyraVideoInitializer" /> <!-- path to your KaleyraVideInitializer implementation -->

</application>

Implement the App Initializer as follows:

package com.example.app

// KaleyraVideoInitializer implementation

class AppKaleyraVideoInitializer : KaleyraVideoInitializer() {
    
    override fun onRequestKaleyraVideoConfigure() {
        if (KaleyraVideo.isConfigured) return
        val configuration = Configuration(
            "appId",
            Environment.Production,
            Region.Europe
        )
        KaleyraVideo.configure(configuration)
    }
    
    override fun onRequestKaleyraVideoConnect() {
        KaleyraVideo.connect("userId") { requestToken("userId") }
    }
    
    override fun dependencies(): List<Class<out Initializer<*>>> = super.dependencies()
}

Optional&Advanced settings

Logging If you want to debug an issue you can plug-in your logging system.

Customize user details The userId cannot describe your users properly so if you would like to display in-chat or in-call users adequately for example name and surname or avatar, you must provide details for user them with UserDetailsProvider interface.

Clone this wiki locally