Making a call

Make a call#

Call feature is essential for the modern day communication. Call sdk allows users to make a one to one audio/video call with the another sdk user.

Note: Permissions are handled in SDK.

Required permissions#

For audio call, the below permissions:

Record Permission

You can use the below method to check audio call permissions:

    CallManager.isAudioCallPermissionsGranted()

    For video call, we need below permissions:

    Record Permission
    Video Permission

    You can use the below method to check video call permissions:

      CallManager.isVideoCallPermissionsGranted()

      Call Metadata#

      To send custom data while making a call, use the optional metaData parameter in all makecall methods.This parameter accepts an array of type CallMetadata

      caution

      Call SDK process only the first three metadata elements, and ensure the metadata doesn't include large data that could interfere with the successful transfer of the VOIP call payload.

      Make a voice call#

      Make voice call feature allows users to make a one to one audio call with the another sdk user along with call metadata. You can make a voice call using the below method.

        try CallManager.makeVoiceCall(TO_USERID, CALL_METADATA) { isSuccess , flyError in
        if isSuccess {
        // SDK will take care of presenting the Call UI. It will present the ViewController that is passed using the method `CallManager.setCallViewController()`
        } else {
        let errorMessage = flyError?.description
        print("makeVoiceCall failed with error \(errorMessage)")
        }
        }
        ArgumentTypeDescription
        TO_USERIDStringId of the callee
        CALL_METADATA[CallMetadata]Optional Call metadata information(Maximum size is 3)
        caution

        If one to one call feature unavailable for your plan then it will throw 403 exception.

        Make a video call#

        Make video call feature allows users to make a one to one video call with the another sdk user along with call metadata. You can make a video call using the below method.

          try CallManager.makeVideoCall(TO_USERID, CALL_METADATA) { isSuccess , flyError in
          if isSuccess {
          // SDK will take care of presenting the Call UI. It will present the ViewController that is passed using the method `CallManager.setCallViewController()`
          } else {
          let errorMessage = flyError?.description
          print("makeVideoCall failed with error \(errorMessage)")
          }
          }
          ArgumentTypeDescription
          TO_USERIDStringId of the callee
          CALL_METADATA[CallMetadata]Optional Call metadata information(Maximum size is 3)
          caution

          If one to one call feature unavailable for your plan then it will throw 403 exception.

          Make a group voice call#

          Make group voice call feature allows users to make a voice call with multiple sdk users along with call metadata. You can make a group voice call using the below method.

            try CallManager.makeGroupVoiceCall(USERID_LIST, GROUP_ID, CALL_METADATA) { isSuccess , flyError in
            if isSuccess {
            // SDK will take care of presenting the Call UI. It will present the ViewController that is passed using the method `CallManager.setCallViewController()`
            } else {
            let errorMessage = flyError?.description
            print("makeGroupVoiceCall failed with error \(errorMessage)")
            }
            }
            ArgumentTypeDescription
            USERID_LIST[String]Userid list of the callee's
            GROUP_IDStringID of the group from which call is initiated
            CALL_METADATA[CallMetadata]Optional Call metadata information(Maximum size is 3)
            caution

            If group call feature unavailable for your plan then it will throw 403 exception.

            Make a group video call#

            Make group video call feature allows users to make a video call with multiple sdk users along with call metadata. You can make a group video call using the below method.

              try CallManager.makeGroupVideoCall(USERID_LIST, GROUP_ID, CALL_METADATA) { isSuccess , flyError in
              if isSuccess {
              // SDK will take care of presenting the Call UI. It will present the ViewController that is passed using the method `CallManager.setCallViewController()`
              } else {
              let errorMessage = flyError?.description
              print("makeGroupVideoCall failed with error \(errorMessage)")
              }
              }
              ArgumentTypeDescription
              USERID_LIST[String]Userid list of the callee's
              GROUP_IDStringID of the group from which call is initiated
              CALL_METADATA[CallMetadata]Optional Call metadata information(Maximum size is 3)
              caution

              If group call feature unavailable for your plan then it will throw 403 exception.

              Add participants to the call#

              After call is connected, you can able to add users to the ongoing call. sdk provides methods to invite users to the call, once they accepted the incoming call, they will join in the ongoing call.

              ArgumentTypeDescription
              USERID_LIST[String]Userid list of the callee's
                CallManager.inviteUsersToOngoingCall(USERID_LIST) { isSuccess , flyError in
                if isSuccess {
                } else {
                let errorMessage = flyError?.description
                print("inviteUsersToOngoingCall failed with error \(errorMessage)")
                }
                }
                caution

                If group call feature unavailable for your plan then it will throw 403 exception.

                Receiving a incoming audio/video call#

                Whenever you receive the audio/video call from the another sdk user, it should be reported to FlyCallSDK through NotificationCenter.

                NotificationCenter.default.post(name: NSNotification.Name("CallPayloadReceived"), object: messageDict)

                Through 'messageDict' pass the payload of the call.

                ParamsTypeDescription
                room_idStringroom id of the call
                call_statusStringstatus of the call
                call_modeStringmode of the call
                call_typeStringtype of the call
                JidStringuser id of the call
                usersStringusers of the call
                inviteStringinvited users of the call
                group_idStringroom id of the call
                meta_dataStringMetadata String

                Disconnect the ongoing call#

                Whenever you make the audio/video call to the another sdk user and you just want to disconnect the call before getting connected or If you want to just disconnect a connected call after the end of conversation, whenever user presses the disconnect button from your call UI , you need to call the below sdk method to disconnect the call and notify the caller.

                  CallManager.disconnectCall()