Browse SDKs · iOS
SDKsiOSEnterprise

Start a one-to-one call

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

Copy

Use signalingInvite:offlinePushInfo:onSuccess:onFailure: to start a one-to-one call. The SDK handles signaling; your app must still connect to the media engine with the credentials returned by the success callback.

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 start the call"];
}];

For a one-to-one call, pass an empty string as groupID. The SDK fills in the inviter and session type. Save the OIMSignalingInfo returned synchronously by the method so it can be used later to cancel or hang up the call and merge state.

The success callback returns an OIMInvitationResultInfo. Connect to the media room only after obtaining a valid token and roomID. Success does not mean that the other user has answered.