Join call via link

Prerequisites#

Call sdk should be initialised for the join call feature.

Get Call link#

When you are in ongoing audio/video call, you can get the call link by using the below method, that you can share with other users to join the call.

    CallManager.getCallLink()

    Preview Screen Options#

    Users can be provided with a preview screen in the UI to observe the call events, render the preview video, switch camera and mute the audio or video even before joining the call. We can make use of the below methods for preview screen implementation. Make sure to ask for the Camera and Microphone access in th UI before joining or subscribing to a call. .

    Preview Video Capturing#

    When you are in the join call UI, you can call the below method to start the video capture.Make use of the UIView RTCMTLVideoView provided by WebRTC Framework to render video. The preview video to render will be available through the onLocalTrack delegate method provided JoinCallDelegate protocol.

      CallManager.startVideoCapture()

      Switch Camera feed#

      Call the below method to switch to front and back camera video feed.

        CallManager.switchCamera()

        Note: you can use the same mute functions for the preview screen from call features link.

        Observing join call events#

        When you are in the join call UI, you might need to observe the call events to update the UI. We can make use of the protocol JoinCallDelegate which has the following methods mentioned below. UI can conform to this protocol and start observing the events.

          func onUsersUpdated(usersList:[String])
          func onLocalTrack(videoTrack: RTCVideoTrack?)
          func onError(reason : String)

          onLocalTrack event will be fired once you called startVideoCapture() from the sdk and all the required permissions were already granted.

          onUsersUpdated event will be fired whenever there is a change in users list for the call, you can use this to update the users list in the join call UI screen as well as you can notify the user that call has been ended when there is no users in the list. Users list is provided as an array of user's id.

          onError event will be fired whenever there is a error occurred while joining the call.

          info

          onUsersUpdated event will be fired with an empty list if the call has been ended you can notify the ui by checking the users count in the list

          Setting the Delegate#

          After conforming to the JoinCallDelegate protocol, call the below method to set the delegate in the sdk.

            CallManager.setJoinCallDelegate(JOIN_CALL_DELEGATE)
            ArgumentTypeDescription
            JOIN_CALL_DELEGATEJoinCallDelegateUIViewController that conforms to the delegate

            Subscribe to call events#

            When you are in the join call UI, you need to subscribe to the call events by using the below method.

              CallManager.subscribeToCallEvents(CALL_ID, USER_NAME){ isSuccess,flyError in }
              ArgumentTypeDescription
              CALL_IDStringGenerated call link id for an ongoing call. E.g. (ght-trt-wkk)
              USER_NAMEStringusername of the current user
              (isSuccess,message)(Bool,String))completion handler to post response

              if isSuccess returns false, then you need to show error message to the user and close the UI.

              Joining the call#

              When you are in the join call UI, you can call the below method to start joining in the ongoing audio/video call.

                CallManager.joinCall { isSuccess,flyError in }

                Clearing join call data#

                Whenever you are leaving from the join call UI, you must call the below method to dispose the call data to avoid memory leaks and unnecessary resource usage. You must call the below method on viewDidDisappear of your UIViewController.

                  CallManager.cleanUpJoinCallViaLink()

                  Getting unknown user name#

                  Whenever you are in the ongoing audio/video call an unknown user can also join the call via link. In this case you can get the unknown user name from the call sdk by providing their user id.

                    let name : String = CallManager.getUserName(USER_ID)
                    ArgumentTypeDescription
                    USER_IDStringuser id of the unknown user
                    info

                    Call Sdk requires chat sdk integration for user management.