Browse SDKs · iOS
Platform
SDKsiOSEnterprise

Start a one-to-one call

Start a one-to-one audio or video call with the OpenIM iOS SDK.

Copy

Initiate a direct audio or video call by dispatching a call invitation. The SDK coordinates signaling exchange and room credential allocation. The application layer consumes the returned room credentials to connect to your WebRTC or RTC media engine.

Parameters

ParameterTypeRequiredDescription
inviteeUserIDListNSArray<NSString *> *YesList of target user IDs. For one-to-one calls, provide exactly one target user ID.
roomIDNSString *YesUnique room identifier, generated as a UUID by the client or provided by your backend.
timeoutNSIntegerYesInvitation timeout duration in seconds.
mediaTypeNSString *YesMedia stream type: @"video" or @"audio".
groupIDNSString *NoTarget group identifier. Pass an empty string @"" for one-to-one calls.

Code example

OIMInvitationInfo *invitation = [OIMInvitationInfo new];
invitation.inviteeUserIDList = @[@"user_b"];
invitation.roomID = NSUUID.UUID.UUIDString.lowercaseString;
invitation.timeout = 30;
invitation.mediaType = @"video";
invitation.groupID = @"";

OIMSignalingInfo *signalingInfo =
    [[OIMManager manager] signalingInvite:invitation
                          offlinePushInfo:push
                                onSuccess:^(OIMInvitationResultInfo * _Nullable credentials) {
        if (credentials != nil) {
            [self joinMediaRoom:credentials];
        }
    }
                                 onFailure:^(NSInteger code, NSString * _Nullable message) {
        [self showCallError:code message:message ?: @"Failed to initiate call"];
    }];

Retain the OIMSignalingInfo object returned synchronously by signalingInvite:...; it stores the active signaling snapshot required to cancel, hang up, or correlate subsequent signaling events.

Return value

The onSuccess callback returns an OIMInvitationResultInfo instance containing the allocated roomID, room access token, streaming liveURL, and busy user list (busyLineUserIDList). Success indicates only that OpenIMServer processed the signaling invitation; it does not indicate that the callee has answered.

State changes after the call

  • Local state merge: Track active call session state using roomID as the primary key and track participant states combining roomID and userID.
  • Remote event notification: The callee receives an incoming invitation notification via onReceiveNewInvitation: in OIMSignalingListener (see Handle call events).
  • Answer detection: The caller tracks whether the callee accepts or rejects the call via the onInviteeAccepted: and onInviteeRejected: delegate callbacks.