Skip to content

Configure KaleyraVideoSDK

Federico Marin edited this page Apr 24, 2024 · 6 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)

KaleyraVideoService

It is strongly recommended to implement the abstract service KaleyraVideoService in order to be notified whenever the KaleyraVideoSDk needs to be configured and connected.

The implementation of the abstract service KaleyraVideoService 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 service KaleyraVideoService please refer to the following snippet:

<!-- app manifest -->

<service
    android:name=".DemoAppKaleyraVideoService"
    android:exported="false">
        <intent-filter>
            <!-- 
              Do not modify this, the action must be set with value "kaleyra_video_sdk_configure" 
              to let this service be started from the KaleyraVideoSDK
            -->
            <action android:name="kaleyra_video_sdk_configure" />
        </intent-filter>
</service>
// KaleyraVideoService implementation

class DemoAppKaleyraVideoService : KaleyraVideoService() {
    
    override suspend fun onRequestKaleyraVideoConfigure(): Unit = configure()

    private fun configure() {
        if (KaleyraVideo.isConfigured) return
        val configuration = Configuration(
            "appId",
            Environment.Production,
            Region.Europe
        )
        KaleyraVideo.configure(configuration)
    }
    
    override fun onRequestKaleyraVideoConnect() = connect()

    private fun connect() {
        KaleyraVideo.connect("userId") { requestToken("userId") }
    }
}

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