Browse SDKs · uni-app / uni-app x
SDKsuni-appEnterprise

Start a one-to-one call

OpenIM uni-app / uni-app x SDK guide for Start a one-to-one call.

Copy

The Commercial signalingInvite() operation starts a one-to-one audio or video call. unix-openim-sdk creates the signaling invitation; the application still joins its media engine with the returned room credentials.

Parameters

ParameterTypeRequiredDescription
invitationOpenIMSignalingInvitationInfoYesInvitation for this call.
invitation.inviterUserIDstringYesCurrent logged-in user ID.
invitation.inviteeUserIDListstring[]YesInvitees; use one peer for a one-to-one call.
invitation.groupIDstringYesUse an empty string for one-to-one calls.
invitation.roomIDstringYesUnique room identifier shared by all call state.
invitation.timeoutnumberYesInvitation timeout in seconds.
invitation.mediaTypestringYesApplication convention such as audio or video.
invitation.sessionTypenumberYesUse OpenIMSessionTypeSingle.
invitation.platformIDnumberYesCurrent native platform constant.
invitation.customDatastringNoApplication extension data.
offlinePushInfoOpenIMSignalingOfflinePushInfoNoOffline push title, description, and iOS settings.
import {
  OpenIMPlatformAndroid,
  OpenIMSessionTypeSingle,
  signalingInvite,
} from '@/uni_modules/unix-openim-sdk'

const roomCredentials = await signalingInvite({
  invitation: {
    inviterUserID: currentUserID,
    inviteeUserIDList: [peerUserID],
    customData: JSON.stringify({ source: 'contact-card' }),
    groupID: '',
    roomID: createBusinessRoomID(),
    timeout: 30,
    mediaType: 'video',
    sessionType: OpenIMSessionTypeSingle,
    platformID: OpenIMPlatformAndroid,
  },
  offlinePushInfo: {
    title: 'Video call',
    desc: 'You have an incoming video call',
    ex: '',
    iOSPushSound: 'default',
    iOSBadgeCount: true,
  },
})

Use OpenIMPlatformIOS on iOS. Generate a stable room ID for this call and keep it consistent across participants.

Result

The Promise resolves to OpenIMSignalingInviteResult | null:

FieldTypeDescription
roomIDstring or nullMedia room identifier.
tokenstring or nullShort-lived room credential.
liveURLstring or nullMedia service connection address.
busyLineUserIDListstring[] or nullUsers who were busy when invited.
invitationOpenIMSignalingInvitationInfo or nullServer invitation snapshot.

Join the media engine only after obtaining a valid room ID and token. Promise success does not mean the peer accepted; merge later state through call events. If the application cannot present outgoing call UI after the invite succeeds, actively cancel the invitation. Never log room credentials.