AKStream.Next · 文档中心

iOS native RTC SDK method reference

iOS native RTC SDK method reference

Applies to the Swift SDK/XCFramework delivered with the matching version. AkNativeRtcClient runs on the main actor and owns the device session, media tracks, WHIP/WHEP, signaling, and recovery. UIKit/SwiftUI hosts own controls, permissions, renderers, audio route, and ReplayKit extension. Follow the iOS integration walkthrough for dependencies and signing first.

let rtc = AkNativeRtcClient(localRenderer: previewRenderer, delegate: self)
rtc.setInitialMediaEnabled(microphone: false, camera: false)
rtc.joinWithAccessTicket(baseURL: serverURL, roomID: roomID,
                             accessTicket: oneUseTicket, passcode: "")

serverURL must use HTTPS with a certificate trusted by the iPhone, not the Mac's 127.0.0.1. The backend ticket is one-use. Call @MainActor methods from the right actor and preserve HTTP status from thrown or delegate errors.

Session, host, and recording

Method Input Result Edge case
AkNativeRtcClient(localRenderer:delegate:) Local RTCVideoRenderer, AkNativeRtcClientDelegate Client SDK observes foreground/background. Keep one active client per meeting.
joinWithAccessTicket(baseURL:roomID:accessTicket:passcode:) Origin, room, one-use ticket, passcode (empty if none) Delegate didJoin or didFailHTTP/didFail Waiting room is not publication permission; ticket replay fails.
createMeeting(settings:creator:) Settings dictionary and business-backend async throws creator Dictionary with roomId/accessTicket Creator authenticates business users and handles idempotent retry; never send admin credentials to the app.
listMembers() / participantForPublication(_:) Publication ID for the latter Member list / member ID or nil Membership/device can change after reconnect; distinguish views by publication ID.
performRoomAction(_:payload:) Allowlisted action and fields async throws -> Any Server rechecks role, device, and grant. Retrying cannot bypass 403.
startContinuousRecording() / stopContinuousRecording(recordingId:) / getContinuousRecording() Run ID for stop Async recording state or no active run Current host starts/stops; didChangeContinuousRecording reports active state.
leave() / close() None Device leaves / object ends Use one cleanup path for navigation. Obtain new business authorization after a kick.
listDemoRooms(baseURL:) / createDemoMeeting(...) / issueDemoAccessTicket(...) Isolated-test options Demo rooms/ticket Not a production identity service.

getContinuousRecording() is the current active run, not historical archives. Post-meeting query and URLs use the separate archive SDK and view/play/download ticket. Host-only recording permission changes immediately after transfer.

Local media, camera, and sharing

Method Input Result Edge case
setInitialMediaEnabled(microphone:camera:) Initial intent Mic/camera startup flags OS permission, meeting grants, and host policy still constrain publication.
setMicrophoneEnabled(_:) / setCameraEnabled(_:) Boolean didChangeLocalMedia reports effective state A button press is not proof of remote frames/audio.
listCameras() / switchCamera(to:) Optional camera ID Device list / didSwitchCamera Position uses AVCaptureDevice.Position; recheck list after permission/device changes.
setRemoteAudioVolume(publicationID:volume:) Publication ID and 0–1 volume Local playback change Does not alter the remote microphone or original recording.
setForeground(_:) Foreground Boolean Capture lifecycle update SDK observes system notifications; custom scene transitions may also need an explicit update.
getSupportedVideoModes() / getEndpointInfo() None Modes / device-info dictionary Supported mode is not actual FPS. Reports omit hardware-unique identifiers.
makeCameraPictureInPicture(sourceView:) Camera UIView AkRtcCameraPictureInPicture or error Local display feature; no extra publication or recording change.
prepareBroadcast(appGroup:) / broadcastIsActive() / stopBroadcastShare() App Group / none ReplayKit preparation, state, stop Requires a signed broadcast extension and matching App Group. The OS can terminate sharing.

Screen and camera are independent streams. A ReplayKit extension captures system content; the main app passes only trusted short-lived session context. Do not log that context or share it with other apps.

Chat, whiteboard, attachments, and events

Method Input Result Edge case
sendChatMessage(_:targetParticipantID:) Text, optional direct target didReceiveChatMessage / error Direct messages do not appear in public replay.
uploadAttachment(data:fileName:contentType:caption:targetParticipantID:) / uploadAttachment(fileURL:caption:targetParticipantID:) Data/file URL, type, caption, target didUploadAttachment / error Commit rechecks current device, room, and direct visibility. Prefer file URL for large files.
uploadWhiteboardImage(fileURL:) Local image file URL async throws -> AkRtcChatAttachment Material upload still needs a board-object event. Revoked write grant blocks final use.
downloadAttachment(_:) / downloadAttachmentFile(_:) / releaseAttachmentFile(_:) Authorized attachment / local temporary URL Data, temp URL, cleanup Use file download for large content and release temporary SDK files.
attachmentPreview(_:maxDimension:) Image attachment and pixel limit UIImage? Non-images or decode failure may return nil. Host chooses PDF/video viewers.
sendHandRaised(_:) / sendReaction(_:) Raised Boolean or reaction Meeting event Does not change publication grant.

Key delegate callbacks: remote video/audio receive and remove manage each view; didChangeLocalMedia and didChangeMediaPermission drive controls; didChangeCapabilities drives host UI; board/chat callbacks drive collaboration; didChangeContinuousRecording drives the indicator; didFailHTTP retains status; nativeRtcClientDidLeave triggers final cleanup. Never revive a new session from stale events of an old session.