Browse SDKs · uni-app / uni-app x
Platform
SDKsuni-app / uni-app xEnterprise

Start a single call

Initiate a one-on-one audio or video call invitation to a specific user.

Copy

Invoke signalingInvite() to initiate a direct one-on-one audio or video call to a target user. Generate a unique roomID for each call session, and retain the invitation payload in local state for subsequent cancellation or hang-up operations.

Parameters

ParameterTypeRequiredDescription
invitationOpenIMSignalingInvitationInfoYesThe signaling invitation configuration object.
invitation.inviterUserIDstringRecommendedThe user ID of the caller initiating the invitation.
invitation.inviteeUserIDListstring[]YesAn array containing exactly one recipient user ID for direct calls.
invitation.groupIDstringRecommendedAn empty string for direct calls.
invitation.roomIDstringYesA unique room identifier generated for this call session.
invitation.timeoutnumberYesRinging timeout duration in seconds.
invitation.mediaTypestringYesMedia type agreed upon by your application, such as 'audio' or 'video'.
invitation.sessionTypeOpenIMSessionTypeYesSupply OpenIMSessionTypeSingle for one-on-one calls.
invitation.platformIDOpenIMPlatformRecommendedCurrent platform constant matching the one used during initSDK().
invitation.customDatastringNoOptional business payload string attached to the invitation.
offlinePushInfoOpenIMSignalingOfflinePushInfoNoOffline push notification configuration for offline invitees.

Code example

import {
  OpenIMSessionTypeSingle,
  signalingInvite,
} from '@/uni_modules/unix-openim-sdk'

const invitation = {
  inviterUserID: currentUserID,
  inviteeUserIDList: [peerUserID],
  customData: JSON.stringify({ source: 'contact-card' }),
  groupID: '',
  roomID: createCallRoomID(),
  timeout: 30,
  mediaType: 'video',
  sessionType: OpenIMSessionTypeSingle,
  platformID: currentOpenIMPlatform,
}

const result = await signalingInvite({
  invitation,
  offlinePushInfo: {
    title: 'Video call',
    desc: 'You received a video call invitation',
    ex: '',
    iOSPushSound: 'default',
    iOSBadgeCount: true,
  },
})

Return value

The Promise resolves with an OpenIMSignalingInviteResult | null object. A non-null result provides invitation, roomID, token, liveURL, and busyLineUserIDList. Join your media engine room only after receiving valid roomID and token credentials.

State changes after the call

A resolved Promise indicates that the signaling invitation was delivered to OpenIMServer and room credentials were generated; it does not mean the callee has answered. Track the call session state using roomID as the primary key. For incoming callee responses and participant lifecycle updates, see Handle call events.