Skip to content

Place calls (inbound calls)

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

User logged-in on mobile sdk calls another user/operator

Add & implement abstract class KaleyraVideoInitializer

This abstract class will be instantiated and called every time the SDK requires to be configured or connected.

onRequestKaleyraVideoConfigure()

This function will be called in the following scenarios:

  • The SDK has not been yet configured.
  • The SDK requires to be configured to be able to connect to the right environment.
  • The SDK has been configured but due to a system behaviour it needs to be renewed.

onRequestKaleyraVideoConnect()

This function will be called in the following scenarios:

  • a kaleyra push notification has been received (with automatic handling strategy -see here for more details )
  • a call/chat has been created from the android client to another endpoint (related to inbound calls use-case)
  • the SDK has been connected and the app has come back to foreground from a background/lockscreen situation.

If correctly implemented the function will connect to Kaleyra services and fetch the calls or chats.

When you implement the connection you will be request to forward a jwt token via a callback accessTokenProvider.

You must get this token from your server that can request it to our server with an authenticated rest see here

Add the following metadata in the Manifest.xml and configure it knowing the behaviour described above.

<!-- app manifest -->

<application>

	[...]

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

</application>

Implement the abstract class KaleyraVideoInitializer 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") }
    }
}
  1. Place the call
val callUI: Result<CallUI> = KaleyraVideo.conference.call(listOf("userB")) {
    preferredType = Call.PreferredType.audioVideo() // or audioUpgradable(), audioOnly() 
    // recordingType = Call.Recording.Type.manual() /* or Call.Recording.Type.automatic() */
    // maxDuration = 60L /* max duration in seconds >= 60 */
}.getOrNull()
Clone this wiki locally