Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Start single call

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

Copy

Generate a unique roomID for each call attempt and preserve the full invitation structure locally to support cancellation, hangup, and UI state restoration.

Code example

import sdk, {
  OfflinePushInfo,
  Platform,
  SessionType,
  SignalingInvitationInfo,
  SignalingInviteReq,
  SignalingInviteResp,
  SignalingMediaType,
  SignalingParticipantMetaData,
} from '@openimsdk/imsdk';

const invitation: SignalingInvitationInfo = {
  inviterUserID: currentUserID,
  inviteeUserIDList: [peerUserID],
  customData: JSON.stringify({ source: 'contact-card' }),
  groupID: '',
  roomID: createCallRoomID(),
  timeout: 30,
  mediaType: SignalingMediaType.SignalingMediaTypeVideo,
  platformID: Platform.HarmonyOS,
  sessionType: SessionType.Single,
  initiateTime: Date.now(),
  busyLineUserIDList: [],
};
const offlinePush: OfflinePushInfo = {
  title: 'Video call',
  desc: 'You have an incoming video call invitation',
  ex: '',
  iOSPushSound: 'default',
  iOSBadgeCount: true,
  SignalingInfo: '',
};
const participant: SignalingParticipantMetaData = { user: selfUser };
const request: SignalingInviteReq = {
  invitation: invitation,
  offlinePush: offlinePush,
  participant: participant,
  userID: peerUserID,
};
const response: SignalingInviteResp = await sdk.signalingInvite(request);

Parameters

ParameterTypeRequiredDescription
invitationSignalingInvitationInfoYesCall invitation payload containing room ID, media type, timeout, and participants.
offlinePushOfflinePushInfoYesPush notification details delivered when the recipient is offline.
participantSignalingParticipantMetaDataYesProfile metadata of the calling user.
userIDstringYesThe target user ID. Must match the element in inviteeUserIDList.

Return value

Returns a Promise that resolves to a SignalingInviteResp object:

PropertyTypeDescription
roomIDstringThe active room identifier.
tokenstringDynamic authentication token required to enter the media room.
liveURLstringStreaming gateway or media server address.
busyLineUserIDListstring[]List of invitees who are currently busy in another call.

State changes after the call

Pass the returned roomID, token, and liveURL to your media engine. Resolving the Promise confirms only that the signaling invite was dispatched to the server; it does not indicate that the callee has answered. Track local outgoing call state using roomID, and listen for accept, reject, cancel, or timeout events via Handle call events.