Skip to content

Access Link

Marco Brescianini edited this page Nov 5, 2024 · 4 revisions

Starting from 3.8.0 version the Kaleyra Video SDK allows performing calls using a call URL without authenticating with an access token. This is an opt-in feature and you are not required to use it. However, if you want to try the SDK or you want your customers to perform a call in a temporary session that lasts as long as the call you can opt-in for this feature.

An access link is just a join call URL. When you create calls using our REST APIs a set of join URLs are created for you, one for each participant. For more information take a look at our REST API documentation

In order to start a call with an access link you must:

Configure the SDK

import UIKit
import KaleyraVideoSDK

@UIApplicationMain
final class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        var config = Config(appID: "My app id", region: .europe, environment: .sandbox)
        config.callKit = .enabled(.init(icon: UIImage(named: "callkit-icon")))
        config.voip = .automatic(listenForNotificationsInForeground: false)

        do {
            try KaleyraVideo.instance.configure(config)
        } catch {
            print("Could not configure the SDK because of \(error)")
        }
        
        return true
    }
}

Join the call

Once the sdk is configured successfully, you can hand it a call URL.

import Foundation
import UIKit
import KaleyraVideoSDK

final class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
        guard userActivity.activityType == NSUserActivityTypeBrowsingWeb else { return }
        guard let url = userActivity.webpageURL else { return }
        
        KaleyraVideo.instance.conference?.join(url: url) { result in }
    }
}

Present the call user interface

import Foundation
import UIKit
import KaleyraVideoSDK

final class MyViewController: UIViewController {

    private lazy var callWindow: CallWindow = .init(windowScene: view.window!.windowScene!)

    override func viewDidLoad() {
        super.viewDidLoad()

        sdk.conference?.callPublisher.compactMap({ $0 }).receive(on: RunLoop.main).sink { [weak self] call in
            self?.present(call: call)
        }.store(in: &subscriptions)
    }

    private func present(call: Call) {
        let controller = CallViewController(call: call, configuration: .init())
        controller.delegate = self
        callWindow.makeKeyAndVisible()
        callWindow.set(rootViewController: controller, animated: true)
    }
}
Clone this wiki locally