tencent cloud

Feedback

TUICalling APIs (iOS)

Last updated: 2022-03-17 15:49:09

    TUICalling is an open-source class based on two closed-source SDKs: Tencent Cloud Real-Time Communication (TRTC) and Instant Messaging (IM). It supports one-to-one and group audio calls. For detailed instructions how to implement it, see Real-Time Audio Call (iOS).

    • TRTC SDK: The TRTC SDK is used as a low-latency audio/video call component.
    • IM SDK: The IM SDK is used to send and process signaling messages.

    TUICalling API Overview

    Basic SDK APIs

    API Description
    sharedInstance Gets a singleton.
    call Sends call invitations by user ID.
    receiveAPNSCalled Answers a call.
    setCallingListener Sets the listener.
    setCallingBell Sets the ringtone (preferably shorter than 30s).
    enableMuteMode Enables/Disables the mute mode.
    enableCustomViewRoute Enables/Disables custom views.

    TUICallingListener API Overview

    Event callbacks

    API Description
    shouldShowOnCallView Callback of whether the answering view is displayed when there is an incoming call
    onCallStart Callback for starting calling. This callback is triggered for both callers and callees.
    onCallEnd Callback for ending a call. This callback is triggered for both callers and callees.
    onCallEvent Call event callback

    Type

    Call type

    Enumerated Type Description
    TUICallingTypeAudio Audio call
    TUICallingTypeVideo Video call

    Role

    Role type

    Enumerated Type Description
    TUICallingRoleCall Caller
    TTUICallingRoleCalled Callee

    Event

    Event type

    Enumerated Type Description
    TUICallingEventCallStart The call started.
    TUICallingEventCallSucceed The call was connected successfully.
    TUICallingEventCallEnd The call ended.
    TUICallingEventCallFailed The call failed.

    Basic SDK APIs

    sharedInstance

    This API is used to get a singleton of the TUICallingManager component.

    + (instancetype)shareInstance;
    

    call

    This API is used to send call invitations by user ID.

    - (void)call:(NSArray<NSString *> *)userIDs type:(TUICallingType)type;
    

    The parameters are as detailed below:

    Parameter Type Description
    userIDs NSArray List of the user IDs of call participants
    type TUICallingType Call type: audio/video

    receiveAPNSCalled

    This API is used to answer a call.

    - (void)receiveAPNSCalled:(NSArray<NSString *> *)userIDs type:(TUICallingType)type;
    

    The parameters are as detailed below:

    Parameter Type Description
    userIDs NSArray List of the user IDs of call participants
    type TUICallingType Call type: audio/video

    setCallingListener

    This API is used to set the listener.

    - (void)setCallingListener:(id<TUICallingListerner>)listener;
    

    The parameters are as detailed below:

    Parameter Type Description
    listener TUICallingListener Listener of the TUIcalling component

    setCallingBell

    This API is used to set the ringtone (preferably shorter than 30s).

    - (void)setCallingBell:(NSString *)filePath;
    

    The parameters are as detailed below:

    Parameter Type Description
    filePath NSString Path of the ringtone file

    enableMuteMode

    This API is used to enable/disable the mute mode.

    - (void)enableMuteMode:(BOOL)enable;
    

    The parameters are as detailed below:

    Parameter Type Description
    enable BOOL Whether to enable the mute mode

    enableCustomViewRoute

    This API is used to enable/disable custom views.
    After enabling custom views, you will receive a CallingViewController instance in the callback for calling/being called, and can decide how to display the view by yourself.

    Note:

    The view must be displayed full screen; otherwise, an error may occur.

    - (void)enableCustomViewRoute:(BOOL)enable;
    

    The parameters are as detailed below:

    Parameter Type Description
    enable BOOL Whether to enable custom views

    TUICallingListener Callback APIs

    shouldShowOnCallView

    Callback of whether the answering view is displayed when there is an incoming call.

    - (BOOL)shouldShowOnCallView;
    

    The parameters are as detailed below:

    Parameter Type Description
    Return value BOOL Whether the answering view is displayed

    onCallStart

    Callback for starting calling, which is triggered for both callers and callees.

    - (void)callStart:(NSArray<NSString *> *)userIDs type:(TUICallingType)type role:(TUICallingRole)role viewController:(UIViewController * _Nullable)viewController;
    

    The parameters are as detailed below:

    Parameter Type Description
    userIDs NSArray List of the user IDs of call participants
    type TUICallingType Call type: audio/video
    role TUICallingRole Role type: caller/callee
    viewController UIViewController Calling view controller

    onCallEnd

    Callback for ending a call, which is triggered for both callers and callees. If enableCustomViewRoute is set to NO, this callback will not be triggered.

    - (void)callEnd:(NSArray<NSString *> *)userIDs type:(TUICallingType)type role:(TUICallingRole)role totalTime:(CGFloat)totalTime;
    

    The parameters are as detailed below:

    Parameter Type Description
    userIDs NSArray List of the user IDs of call participants
    type TUICallingType Call type: audio/video
    role TUICallingRole Role type: caller/callee
    totalTime CGFloat Call duration (s)

    onCallEvent

    Call event callback, which is triggered for both callers and callees. If enableCustomViewRoute is set to NO, this callback will not be triggered.

    - (void)onCallEvent:(TUICallingEvent)event type:(TUICallingType)type role:(TUICallingRole)role message:(NSString *)message;
    

    The parameters are as detailed below:

    Parameter Type Description
    event TUICallingEvent Call event type
    type TUICallingType Call type: audio/video
    role TUICallingRole Role type: caller/callee
    message NSString Event description
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support