@tencentcloud/sdk-mcp 1.4.7 → 1.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +0 -1
- package/knowledge/bm25-cache.js +73 -0
- package/knowledge/bm25.js +147 -0
- package/knowledge/build-index.js +65 -0
- package/knowledge/chunker.js +167 -0
- package/knowledge/content-loader.js +44 -0
- package/knowledge/extractors.js +25 -0
- package/knowledge/path-meta.js +175 -0
- package/knowledge/search/exact-lookup.js +330 -0
- package/knowledge/search/filter-pool.js +86 -0
- package/knowledge/search/requires-framework.js +72 -0
- package/knowledge/search/search-knowledge.js +226 -0
- package/package.json +9 -9
- package/resource/_schema/feature-aliases.yaml +10 -0
- package/resource/_schema/goal-tags.yaml +72 -0
- package/resource/_schema/products.yaml +16 -0
- package/resource/_schema/trtc-intents.yaml +27 -0
- package/resource/_schema/types.yaml +44 -0
- package/resource/index/component-slugs.json +1 -0
- package/resource/index/manifest.json +1 -0
- package/resource/{doc → integration}/callkit/preset/android/integration.md +32 -28
- package/resource/{doc → integration}/callkit/preset/flutter/integration.md +109 -54
- package/resource/integration/callkit/preset/ios/integration.md +411 -0
- package/resource/integration/callkit/preset/react/integration.md +499 -0
- package/resource/integration/callkit/preset/vue/integration.md +768 -0
- package/resource/{doc/chatkit → integration/chat/preset}/android/integration.md +11 -11
- package/resource/{doc/chatkit → integration/chat/preset}/flutter/integration.md +59 -37
- package/resource/integration/chat/preset/ios/integration.md +568 -0
- package/resource/{doc/chatkit → integration/chat/preset}/react/integration.md +127 -95
- package/resource/integration/chat/preset/uni-app/integration.md +494 -0
- package/resource/{doc/chatkit → integration/chat/preset}/vue/integration.md +163 -143
- package/resource/{doc → integration}/livekit/preset/live/vue/live-list-integration.md +15 -15
- package/resource/{doc → integration}/livekit/preset/live/vue/live-player-desk-integration.md +25 -13
- package/resource/{doc → integration}/livekit/preset/live/vue/live-player-h5-integration.md +15 -9
- package/resource/{doc → integration}/livekit/preset/live/vue/live-pusher-integration.md +31 -26
- package/resource/integration/roomkit/preset/vue/integration.md +571 -0
- package/resource/knowledge/callkit/core-sdk/android/answer-call.md +852 -0
- package/resource/knowledge/callkit/core-sdk/android/make-call.md +929 -0
- package/resource/knowledge/callkit/core-sdk/android/offline-push.md +364 -0
- package/resource/knowledge/callkit/core-sdk/flutter/answer-call.md +1150 -0
- package/resource/knowledge/callkit/core-sdk/flutter/make-call.md +1216 -0
- package/resource/knowledge/callkit/core-sdk/flutter/offline-push.md +412 -0
- package/resource/knowledge/callkit/core-sdk/ios/answer-call.md +1191 -0
- package/resource/knowledge/callkit/core-sdk/ios/make-call.md +1292 -0
- package/resource/knowledge/callkit/core-sdk/ios/offline-push.md +537 -0
- package/resource/knowledge/callkit/core-sdk/uni-app/answer-call.md +953 -0
- package/resource/knowledge/callkit/core-sdk/uni-app/make-call.md +1061 -0
- package/resource/knowledge/callkit/faq/android.md +168 -0
- package/resource/knowledge/callkit/faq/common.md +180 -0
- package/resource/knowledge/callkit/faq/flutter.md +52 -0
- package/resource/knowledge/callkit/faq/ios.md +116 -0
- package/resource/knowledge/callkit/faq/uniapp-app.md +89 -0
- package/resource/knowledge/callkit/faq/uniapp-miniprogram.md +217 -0
- package/resource/knowledge/callkit/faq/web.md +363 -0
- package/resource/knowledge/callkit/preset/android/api.md +413 -0
- package/resource/knowledge/callkit/preset/flutter/api.md +22 -0
- package/resource/knowledge/callkit/preset/ios/api.md +256 -0
- package/resource/knowledge/callkit/preset/web/api.md +79 -0
- package/resource/knowledge/chat/preset/android/features/chat-setting.md +72 -0
- package/resource/knowledge/chat/preset/android/features/contact-list.md +41 -0
- package/resource/knowledge/chat/preset/android/features/conversation-list.md +123 -0
- package/resource/knowledge/chat/preset/android/features/language.md +142 -0
- package/resource/knowledge/chat/preset/android/features/message-input.md +57 -0
- package/resource/knowledge/chat/preset/android/features/message-list.md +142 -0
- package/resource/knowledge/chat/preset/android/features/search.md +64 -0
- package/resource/{doc/chatkit → knowledge/chat/preset}/android/features/theme.md +21 -18
- package/resource/knowledge/chat/preset/android-view/integration.md +448 -0
- package/resource/knowledge/chat/preset/flutter/features/chat-setting.md +62 -0
- package/resource/knowledge/chat/preset/flutter/features/contact-list.md +40 -0
- package/resource/knowledge/chat/preset/flutter/features/conversation-list.md +129 -0
- package/resource/knowledge/chat/preset/flutter/features/language.md +104 -0
- package/resource/knowledge/chat/preset/flutter/features/message-input.md +54 -0
- package/resource/knowledge/chat/preset/flutter/features/message-list.md +163 -0
- package/resource/knowledge/chat/preset/flutter/features/search.md +59 -0
- package/resource/{doc/chatkit → knowledge/chat/preset}/flutter/features/theme.md +47 -19
- package/resource/knowledge/chat/preset/ios/features/chat-setting.md +92 -0
- package/resource/knowledge/chat/preset/ios/features/contact-list.md +119 -0
- package/resource/knowledge/chat/preset/ios/features/conversation-list.md +134 -0
- package/resource/knowledge/chat/preset/ios/features/language.md +105 -0
- package/resource/knowledge/chat/preset/ios/features/message-input.md +69 -0
- package/resource/knowledge/chat/preset/ios/features/message-list.md +164 -0
- package/resource/knowledge/chat/preset/ios/features/search.md +94 -0
- package/resource/{doc/chatkit → knowledge/chat/preset}/ios/features/theme.md +54 -51
- package/resource/{doc/chatkit/ios → knowledge/chat/preset/ios-uikit}/integration.md +157 -94
- package/resource/knowledge/chat/preset/react/features/chat-setting.md +123 -0
- package/resource/{doc/chatkit/react/components → knowledge/chat/preset/react/features}/contact-list.md +256 -104
- package/resource/knowledge/chat/preset/react/features/conversation-actions.md +217 -0
- package/resource/{doc/chatkit/react/components → knowledge/chat/preset/react/features}/conversation-list.md +86 -79
- package/resource/knowledge/chat/preset/react/features/conversation-preview.md +99 -0
- package/resource/knowledge/chat/preset/react/features/conversation-search.md +58 -0
- package/resource/{doc/chatkit/react/components → knowledge/chat/preset/react/features}/message-input.md +30 -83
- package/resource/{doc/chatkit/react/components → knowledge/chat/preset/react/features}/message-list.md +22 -25
- package/resource/knowledge/chat/preset/react/features/search.md +531 -0
- package/resource/knowledge/chat/preset/react/features/theme.md +16 -0
- package/resource/knowledge/chat/preset/vue/features/chat-header.md +331 -0
- package/resource/{doc/chatkit/vue/components → knowledge/chat/preset/vue/features}/chat-setting.md +0 -4
- package/resource/{doc/chatkit/vue/components → knowledge/chat/preset/vue/features}/contact-list.md +59 -53
- package/resource/{doc/chatkit/vue/components → knowledge/chat/preset/vue/features}/conversation-actions.md +49 -43
- package/resource/{doc/chatkit/vue/components → knowledge/chat/preset/vue/features}/conversation-list.md +61 -49
- package/resource/{doc/chatkit/vue/components → knowledge/chat/preset/vue/features}/conversation-preview.md +43 -40
- package/resource/{doc/chatkit/vue/components → knowledge/chat/preset/vue/features}/conversation-search.md +1 -1
- package/resource/{doc/chatkit/vue/components → knowledge/chat/preset/vue/features}/message-input.md +128 -105
- package/resource/{doc/chatkit/vue/components → knowledge/chat/preset/vue/features}/message-list.md +108 -195
- package/resource/{doc/chatkit/vue/components → knowledge/chat/preset/vue/features}/search.md +74 -68
- package/resource/knowledge/chat/preset/vue/features/theme.md +136 -0
- package/resource/knowledge/chat/urls/error-code.md +16 -0
- package/resource/knowledge/chat/urls/product.md +61 -0
- package/resource/knowledge/chat/urls/restapi.md +226 -0
- package/resource/knowledge/chat/urls/sdk/android.md +84 -0
- package/resource/knowledge/chat/urls/sdk/flutter.md +73 -0
- package/resource/knowledge/chat/urls/sdk/ios.md +84 -0
- package/resource/knowledge/chat/urls/sdk/web.md +88 -0
- package/resource/knowledge/chat/urls/webhook.md +73 -0
- package/resource/{doc/livekit/core-sdk/live/android/api-reference → knowledge/livekit/core-sdk/api-reference/android}/AudioEffectStore.md +79 -76
- package/resource/knowledge/livekit/core-sdk/api-reference/android/BarrageStore.md +174 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/BattleStore.md +329 -0
- package/resource/{doc/livekit/core-sdk/live/android/api-reference → knowledge/livekit/core-sdk/api-reference/android}/CameraView.md +7 -6
- package/resource/knowledge/livekit/core-sdk/api-reference/android/CoGuestStore.md +434 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/CoHostStore.md +362 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/DeviceStore.md +466 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/GiftStore.md +173 -0
- package/resource/{doc/livekit/core-sdk/live/android/api-reference → knowledge/livekit/core-sdk/api-reference/android}/LikeStore.md +12 -10
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LiveAudienceStore.md +291 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LiveCoreView.md +78 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LiveSeatStore.md +439 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LoginStore.md +221 -0
- package/resource/{doc/livekit/core-sdk/live/flutter/api-reference → knowledge/livekit/core-sdk/api-reference/flutter}/AudioEffectStore.md +79 -76
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/BarrageStore.md +212 -0
- package/resource/{doc/livekit/core-sdk/live/flutter/api-reference → knowledge/livekit/core-sdk/api-reference/flutter}/BaseBeautyStore.md +43 -45
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/BattleStore.md +312 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/CoGuestStore.md +404 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/CoHostStore.md +334 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/DeviceStore.md +420 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/GiftStore.md +166 -0
- package/resource/{doc/livekit/core-sdk/live/flutter/api-reference → knowledge/livekit/core-sdk/api-reference/flutter}/LikeStore.md +12 -11
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LiveAudienceStore.md +281 -0
- package/resource/{doc/livekit/core-sdk/live/flutter/api-reference → knowledge/livekit/core-sdk/api-reference/flutter}/LiveCoreView.md +49 -42
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LiveSeatStore.md +397 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LoginStore.md +183 -0
- package/resource/{doc/livekit/core-sdk/live/ios/api-reference → knowledge/livekit/core-sdk/api-reference/ios}/AudioEffectStore.md +79 -75
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/BarrageStore.md +192 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/BaseBeautyStore.md +146 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/BattleStore.md +309 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/CoGuestStore.md +370 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/CoHostStore.md +339 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/DeviceStore.md +503 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/GiftStore.md +188 -0
- package/resource/{doc/livekit/core-sdk/live/ios/api-reference → knowledge/livekit/core-sdk/api-reference/ios}/LikeStore.md +12 -10
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LiveAudienceStore.md +289 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LiveCoreView.md +78 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LiveSeatStore.md +434 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LoginStore.md +187 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/web/index.md +780 -0
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-audience-list.md +59 -51
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-audio-effect.md +37 -34
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-barrage.md +68 -38
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-base-beauty.md +18 -15
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-co-guest-interaction.md +17 -17
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-gift.md +86 -80
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-host-interaction.md +53 -49
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-integration.md +47 -45
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-live-list.md +26 -22
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-audience-list.md +16 -13
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-audio-effect.md +28 -24
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-barrage.md +33 -21
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-base-beauty.md +29 -25
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-co-guest-interaction.md +21 -20
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-gift.md +78 -69
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-host-interaction.md +47 -43
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-integration.md +48 -45
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-live-list.md +27 -23
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-audience-list.md +15 -12
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-audio-effect.md +39 -36
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-barrage.md +42 -29
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-base-beauty.md +19 -16
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-co-guest-interaction.md +20 -19
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-gift.md +55 -49
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-host-interaction.md +50 -46
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-integration.md +48 -46
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-live-list.md +26 -22
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-audience-list.md +59 -51
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-audio-effect.md +41 -38
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-barrage.md +67 -37
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-co-guest-interaction.md +53 -46
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-gift.md +86 -80
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-host-interaction.md +45 -40
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-integration.md +43 -42
- package/resource/knowledge/livekit/core-sdk/voice/android/voice-room-list.md +523 -0
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/flutter/voice-audience-list.md +16 -13
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/flutter/voice-audio-effect.md +54 -50
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/flutter/voice-barrage.md +33 -21
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/flutter/voice-co-guest-interaction.md +34 -28
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/flutter/voice-gift.md +73 -64
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/flutter/voice-integration.md +46 -43
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/flutter/voice-room-list.md +165 -148
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-audience-list.md +19 -16
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-audio-effect.md +40 -37
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-barrage.md +41 -28
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-co-guest-interaction.md +54 -47
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-gift.md +52 -46
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-host-interaction.md +55 -50
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-integration.md +47 -45
- package/resource/knowledge/livekit/core-sdk/voice/ios/voice-room-list.md +404 -0
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/uni-app/voice-audience-list.md +40 -57
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/uni-app/voice-audio-effect.md +38 -49
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/uni-app/voice-barrage.md +53 -53
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/uni-app/voice-co-guest-interaction.md +106 -116
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/uni-app/voice-gift.md +49 -59
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/uni-app/voice-integration.md +52 -45
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/uni-app/voice-room-list.md +38 -46
- package/resource/knowledge/livekit/preset/live/vue/features/barrage.md +915 -0
- package/resource/knowledge/livekit/preset/live/vue/features/live-audience-list.md +179 -0
- package/resource/knowledge/livekit/preset/live/vue/features/live-view.md +419 -0
- package/resource/knowledge/push/config/android/fcm.md +133 -0
- package/resource/knowledge/push/config/android/honor.md +111 -0
- package/resource/knowledge/push/config/android/huawei.md +106 -0
- package/resource/knowledge/push/config/android/meizu.md +121 -0
- package/resource/knowledge/push/config/android/oppo.md +108 -0
- package/resource/knowledge/push/config/android/vivo.md +101 -0
- package/resource/knowledge/push/config/android/xiaomi.md +99 -0
- package/resource/knowledge/push/integration/android.md +1028 -0
- package/resource/knowledge/push/integration/donut.md +271 -0
- package/resource/knowledge/push/integration/flutter.md +363 -0
- package/resource/knowledge/push/integration/harmonyos.md +72 -0
- package/resource/knowledge/push/integration/ios.md +705 -0
- package/resource/knowledge/push/integration/react-native.md +337 -0
- package/resource/knowledge/push/integration/uni-app.md +461 -0
- package/resource/knowledge/push/integration/unity.md +357 -0
- package/resource/knowledge/push/integration/unreal-engine.md +353 -0
- package/resource/knowledge/push/overview/prepare.md +30 -0
- package/resource/{doc/roomkit/android/features → knowledge/roomkit/core-sdk/android}/call-user-to-room.md +22 -20
- package/resource/{doc/roomkit/android/features → knowledge/roomkit/core-sdk/android}/room-participant-state.md +22 -193
- package/resource/{doc/roomkit/android/features → knowledge/roomkit/core-sdk/android}/room-state.md +33 -32
- package/resource/{doc/roomkit/android/features → knowledge/roomkit/core-sdk/android}/schedule-room.md +30 -29
- package/resource/knowledge/roomkit/core-sdk/flutter/call-user-to-room.md +230 -0
- package/resource/{doc/roomkit/flutter/features → knowledge/roomkit/core-sdk/flutter}/room-participant-state.md +22 -21
- package/resource/{doc/roomkit/flutter/features → knowledge/roomkit/core-sdk/flutter}/room-state.md +29 -28
- package/resource/{doc/roomkit/flutter/features → knowledge/roomkit/core-sdk/flutter}/schedule-room.md +17 -16
- package/resource/{doc/roomkit/ios/features → knowledge/roomkit/core-sdk/ios}/call-user-to-room.md +22 -20
- package/resource/{doc/roomkit/ios/features → knowledge/roomkit/core-sdk/ios}/room-participant-state.md +49 -218
- package/resource/{doc/roomkit/ios/features → knowledge/roomkit/core-sdk/ios}/room-state.md +37 -37
- package/resource/{doc/roomkit/ios/features → knowledge/roomkit/core-sdk/ios}/schedule-room.md +28 -28
- package/resource/{doc/roomkit/vue/features → knowledge/roomkit/core-sdk/vue}/call-user-to-room.md +122 -7
- package/resource/{doc/roomkit/vue/features → knowledge/roomkit/core-sdk/vue}/device-detection.md +318 -3
- package/resource/knowledge/roomkit/core-sdk/vue/device-state.md +1504 -0
- package/resource/{doc/roomkit/vue/features → knowledge/roomkit/core-sdk/vue}/free-beauty-panel.md +4 -3
- package/resource/knowledge/roomkit/core-sdk/vue/room-chat.md +709 -0
- package/resource/knowledge/roomkit/core-sdk/vue/room-participant-state.md +1105 -0
- package/resource/knowledge/roomkit/core-sdk/vue/room-state.md +635 -0
- package/resource/knowledge/roomkit/core-sdk/vue/room-view.md +529 -0
- package/resource/{doc/roomkit/vue/features → knowledge/roomkit/core-sdk/vue}/schedule-room.md +256 -13
- package/resource/{doc/roomkit/vue/features → knowledge/roomkit/core-sdk/vue}/screen-share.md +218 -25
- package/resource/{doc/roomkit/vue/features → knowledge/roomkit/core-sdk/vue}/virtual-background.md +4 -3
- package/resource/{doc/roomkit → knowledge/roomkit/preset}/android/integration.md +50 -64
- package/resource/{doc/roomkit → knowledge/roomkit/preset}/flutter/integration.md +34 -31
- package/resource/{doc/roomkit → knowledge/roomkit/preset}/ios/integration.md +45 -53
- package/resource/knowledge/roomkit/preset/react/integration.md +571 -0
- package/resource/{doc → knowledge}/rtcengine/web/how_to_run_web_sdk_demo.md +31 -15
- package/resource/{doc → knowledge}/rtcengine/web/plugin/21-advanced-auto-play-policy.md +9 -3
- package/resource/{doc → knowledge}/rtcengine/web/plugin/22-advanced-audio-mixer.md +1 -1
- package/resource/{doc → knowledge}/rtcengine/web/plugin/23-advanced-support-detection.md +1 -1
- package/resource/{doc → knowledge}/rtcengine/web/plugin/24-advanced-network-quality.md +6 -6
- package/resource/{doc → knowledge}/rtcengine/web/plugin/25-advanced-device-change.md +1 -1
- package/resource/{doc → knowledge}/rtcengine/web/plugin/26-advanced-publish-cdn-stream.md +4 -4
- package/resource/{doc → knowledge}/rtcengine/web/plugin/27-advanced-small-stream.md +4 -4
- package/resource/{doc → knowledge}/rtcengine/web/plugin/31-advanced-plugins-overview.md +1 -1
- package/resource/{doc → knowledge}/trtc/android/TRTCCloud.md +547 -495
- package/resource/{doc → knowledge}/trtc/android/TRTCCloudDef.md +434 -403
- package/resource/{doc → knowledge}/trtc/android/TRTCCloudListener.md +394 -348
- package/resource/{doc → knowledge}/trtc/android/TRTCStatistics.md +17 -15
- package/resource/{doc → knowledge}/trtc/android/TXAudioEffectManager.md +227 -197
- package/resource/knowledge/trtc/android/TXBeautyManager.md +415 -0
- package/resource/{doc → knowledge}/trtc/android/TXDeviceManager.md +70 -63
- package/resource/{doc → knowledge}/trtc/android/TXLiteAVCode.md +19 -17
- package/resource/{doc/trtc/C++ → knowledge/trtc/c++}/ITRTCCloud.md +599 -544
- package/resource/{doc/trtc/C++ → knowledge/trtc/c++}/ITRTCStatistics.md +17 -15
- package/resource/knowledge/trtc/c++/ITXAudioEffectManager.md +502 -0
- package/resource/knowledge/trtc/c++/ITXDeviceManager.md +403 -0
- package/resource/{doc/trtc/C++ → knowledge/trtc/c++}/TRTCCloudCallback.md +439 -387
- package/resource/{doc/trtc/C++ → knowledge/trtc/c++}/TRTCTypeDef.md +417 -387
- package/resource/{doc/trtc/C++ → knowledge/trtc/c++}/TXLiteAVCode.md +19 -17
- package/resource/{doc/trtc/iOS → knowledge/trtc/ios}/TRTCCloud.md +619 -559
- package/resource/{doc/trtc/iOS → knowledge/trtc/ios}/TRTCCloudDelegate.md +409 -360
- package/resource/{doc/trtc/iOS → knowledge/trtc/ios}/TRTCStatistics.md +17 -15
- package/resource/{doc/trtc/iOS → knowledge/trtc/ios}/TXAudioEffectManager.md +187 -164
- package/resource/knowledge/trtc/ios/TXBeautyManager.md +416 -0
- package/resource/knowledge/trtc/ios/TXDeviceManager.md +399 -0
- package/resource/{doc/trtc/iOS → knowledge/trtc/ios}/TXLiteAVCode.md +19 -17
- package/resource/{doc/trtc/iOS → knowledge/trtc/ios}/TXLiveSDKTypeDef.md +422 -396
- package/server-config.js +0 -1
- package/server.js +22 -12
- package/streamable-http.js +0 -1
- package/tools/call/get_native_call_uikit_integration.js +2 -4
- package/tools/call/get_native_callkit_core_integration.js +2 -6
- package/tools/call/get_web_call_uikit_integration.js +2 -4
- package/tools/chat/get_native_chat_uikit_integration.js +2 -4
- package/tools/chat/get_web_chat_uikit_integration.js +2 -4
- package/tools/common/get_usersig.js +0 -1
- package/tools/common/present_framework_choice.js +9 -4
- package/tools/common/record_answer.js +19 -26
- package/tools/common/record_feedback.js +17 -31
- package/tools/common/search_trtc_knowledge.js +44 -0
- package/tools/definitions/get_native_call_uikit_integration_def.js +2 -1
- package/tools/definitions/get_native_callkit_core_integration_def.js +2 -1
- package/tools/definitions/get_native_chat_uikit_integration_def.js +3 -2
- package/tools/definitions/get_native_livekit_core_integration_def.js +2 -1
- package/tools/definitions/get_usersig_def.js +0 -1
- package/tools/definitions/get_web_call_uikit_integration_def.js +2 -1
- package/tools/definitions/get_web_chat_uikit_integration_def.js +2 -1
- package/tools/definitions/get_web_live_uikit_integration_def.js +4 -3
- package/tools/definitions/get_web_room_core_integration_def.js +46 -0
- package/tools/definitions/get_web_room_uikit_integration_def.js +3 -1
- package/tools/definitions/integration-boundary.js +5 -0
- package/tools/definitions/present_framework_choice_def.js +11 -10
- package/tools/definitions/record_answer_def.js +6 -5
- package/tools/definitions/record_feedback_def.js +4 -3
- package/tools/definitions/search_trtc_knowledge_def.js +69 -0
- package/tools/index.js +5 -37
- package/tools/live/get_native_livekit_core_integration.js +1 -4
- package/tools/live/get_web_live_uikit_integration.js +2 -5
- package/tools/room/get_web_room_core_integration.js +47 -0
- package/tools/room/get_web_room_uikit_integration.js +2 -4
- package/utils/generate-structured-result.js +4 -11
- package/utils/generate-usersig.js +0 -1
- package/utils/get-device-identifier.js +0 -1
- package/utils/get-doc-content.js +14 -9
- package/utils/http-get.js +0 -1
- package/utils/http-post.js +0 -1
- package/utils/report-cls-client.js +22 -21
- package/utils/report-es-client.js +1 -2
- package/utils/report-runtime-error-cls-client.js +0 -1
- package/index.js.map +0 -1
- package/resource/doc/callkit/core-sdk/.gitkeep +0 -0
- package/resource/doc/callkit/core-sdk/android/answer-call.md +0 -942
- package/resource/doc/callkit/core-sdk/android/make-call.md +0 -876
- package/resource/doc/callkit/core-sdk/android/offline-push.md +0 -368
- package/resource/doc/callkit/core-sdk/flutter/answer-call.md +0 -1132
- package/resource/doc/callkit/core-sdk/flutter/make-call.md +0 -1206
- package/resource/doc/callkit/core-sdk/flutter/offline-push.md +0 -357
- package/resource/doc/callkit/core-sdk/ios/answer-call.md +0 -1009
- package/resource/doc/callkit/core-sdk/ios/make-call.md +0 -1154
- package/resource/doc/callkit/core-sdk/ios/offline-push.md +0 -470
- package/resource/doc/callkit/core-sdk/uni-app/answer-call.md +0 -1146
- package/resource/doc/callkit/core-sdk/uni-app/make-call.md +0 -1267
- package/resource/doc/callkit/faq/android-faq.md +0 -767
- package/resource/doc/callkit/faq/flutter-faq.md +0 -749
- package/resource/doc/callkit/faq/ios-faq.md +0 -759
- package/resource/doc/callkit/faq/web-faq.md +0 -753
- package/resource/doc/callkit/preset/android/api.md +0 -330
- package/resource/doc/callkit/preset/flutter/api.md +0 -401
- package/resource/doc/callkit/preset/ios/api.md +0 -282
- package/resource/doc/callkit/preset/ios/integration.md +0 -188
- package/resource/doc/callkit/preset/react/api.md +0 -600
- package/resource/doc/callkit/preset/react/integration.md +0 -86
- package/resource/doc/callkit/preset/vue/api.md +0 -600
- package/resource/doc/callkit/preset/vue/integration.md +0 -83
- package/resource/doc/chatkit/android/faq.md +0 -109
- package/resource/doc/chatkit/faq/android_sdk/client-api.md +0 -280
- package/resource/doc/chatkit/faq/common/product.md +0 -82
- package/resource/doc/chatkit/faq/common/server.md +0 -53
- package/resource/doc/chatkit/faq/common/server_error_code.md +0 -74
- package/resource/doc/chatkit/faq/flutter_sdk/client-api.md +0 -183
- package/resource/doc/chatkit/faq/flutter_sdk/faq.md +0 -54
- package/resource/doc/chatkit/faq/ios_sdk/client-api.md +0 -279
- package/resource/doc/chatkit/faq/web_sdk/error_code.md +0 -47
- package/resource/doc/chatkit/faq/web_sdk/faq.md +0 -292
- package/resource/doc/chatkit/flutter/faq.md +0 -22
- package/resource/doc/chatkit/ios/faq.md +0 -109
- package/resource/doc/chatkit/react/components/avatar.md +0 -104
- package/resource/doc/chatkit/react/components/chat-header.md +0 -148
- package/resource/doc/chatkit/react/components/chat-setting.md +0 -117
- package/resource/doc/chatkit/react/components/chat.md +0 -38
- package/resource/doc/chatkit/react/components/component-list.md +0 -35
- package/resource/doc/chatkit/react/components/conversation-actions.md +0 -174
- package/resource/doc/chatkit/react/components/conversation-preview.md +0 -116
- package/resource/doc/chatkit/react/components/conversation-search.md +0 -57
- package/resource/doc/chatkit/react/components/search.md +0 -282
- package/resource/doc/chatkit/react/components/tuikit.md +0 -43
- package/resource/doc/chatkit/react/faq.md +0 -26
- package/resource/doc/chatkit/vue/components/avatar.md +0 -104
- package/resource/doc/chatkit/vue/components/chat-header.md +0 -149
- package/resource/doc/chatkit/vue/components/chat.md +0 -42
- package/resource/doc/chatkit/vue/components/component-list.md +0 -89
- package/resource/doc/chatkit/vue/components/tuikit.md +0 -45
- package/resource/doc/chatkit/vue/components/userpicker.md +0 -256
- package/resource/doc/chatkit/vue/faq.md +0 -35
- package/resource/doc/livekit/core-sdk/live/android/api-reference/BarrageStore.md +0 -148
- package/resource/doc/livekit/core-sdk/live/android/api-reference/BattleStore.md +0 -316
- package/resource/doc/livekit/core-sdk/live/android/api-reference/CoGuestStore.md +0 -419
- package/resource/doc/livekit/core-sdk/live/android/api-reference/CoHostStore.md +0 -325
- package/resource/doc/livekit/core-sdk/live/android/api-reference/DeviceStore.md +0 -436
- package/resource/doc/livekit/core-sdk/live/android/api-reference/GiftStore.md +0 -165
- package/resource/doc/livekit/core-sdk/live/android/api-reference/LiveAudienceStore.md +0 -239
- package/resource/doc/livekit/core-sdk/live/android/api-reference/LiveCoreView.md +0 -74
- package/resource/doc/livekit/core-sdk/live/android/api-reference/LiveSeatStore.md +0 -417
- package/resource/doc/livekit/core-sdk/live/android/api-reference/LoginStore.md +0 -207
- package/resource/doc/livekit/core-sdk/live/flutter/api-reference/BarrageStore.md +0 -158
- package/resource/doc/livekit/core-sdk/live/flutter/api-reference/BattleStore.md +0 -304
- package/resource/doc/livekit/core-sdk/live/flutter/api-reference/CoGuestStore.md +0 -394
- package/resource/doc/livekit/core-sdk/live/flutter/api-reference/CoHostStore.md +0 -303
- package/resource/doc/livekit/core-sdk/live/flutter/api-reference/DeviceStore.md +0 -410
- package/resource/doc/livekit/core-sdk/live/flutter/api-reference/GiftStore.md +0 -160
- package/resource/doc/livekit/core-sdk/live/flutter/api-reference/LiveAudienceStore.md +0 -231
- package/resource/doc/livekit/core-sdk/live/flutter/api-reference/LiveSeatStore.md +0 -375
- package/resource/doc/livekit/core-sdk/live/flutter/api-reference/LoginStore.md +0 -170
- package/resource/doc/livekit/core-sdk/live/ios/api-reference/BarrageStore.md +0 -165
- package/resource/doc/livekit/core-sdk/live/ios/api-reference/BaseBeautyStore.md +0 -143
- package/resource/doc/livekit/core-sdk/live/ios/api-reference/BattleStore.md +0 -298
- package/resource/doc/livekit/core-sdk/live/ios/api-reference/CoGuestStore.md +0 -349
- package/resource/doc/livekit/core-sdk/live/ios/api-reference/CoHostStore.md +0 -297
- package/resource/doc/livekit/core-sdk/live/ios/api-reference/DeviceStore.md +0 -471
- package/resource/doc/livekit/core-sdk/live/ios/api-reference/GiftStore.md +0 -179
- package/resource/doc/livekit/core-sdk/live/ios/api-reference/LiveAudienceStore.md +0 -238
- package/resource/doc/livekit/core-sdk/live/ios/api-reference/LiveCoreView.md +0 -74
- package/resource/doc/livekit/core-sdk/live/ios/api-reference/LiveSeatStore.md +0 -412
- package/resource/doc/livekit/core-sdk/live/ios/api-reference/LoginStore.md +0 -173
- package/resource/doc/livekit/core-sdk/voice/android/voice-room-list.md +0 -365
- package/resource/doc/livekit/core-sdk/voice/ios/voice-room-list.md +0 -336
- package/resource/doc/livekit/preset/live/vue/api-reference/index.md +0 -780
- package/resource/doc/livekit/preset/live/vue/components/barrage.md +0 -291
- package/resource/doc/livekit/preset/live/vue/components/co-guest-panel.md +0 -88
- package/resource/doc/livekit/preset/live/vue/components/live-audience-list.md +0 -164
- package/resource/doc/livekit/preset/live/vue/components/live-scene-panel.md +0 -130
- package/resource/doc/livekit/preset/live/vue/components/live-view.md +0 -203
- package/resource/doc/livekit/preset/live/vue/components/stream-mixer.md +0 -211
- package/resource/doc/livekit/preset/live/vue/faq.md +0 -1
- package/resource/doc/roomkit/faq/common/error-code.md +0 -67
- package/resource/doc/roomkit/flutter/features/call-user-to-room.md +0 -228
- package/resource/doc/roomkit/vue/faq.md +0 -1
- package/resource/doc/roomkit/vue/features/device-state.md +0 -460
- package/resource/doc/roomkit/vue/features/room-chat.md +0 -369
- package/resource/doc/roomkit/vue/features/room-participant-state.md +0 -385
- package/resource/doc/roomkit/vue/features/room-state.md +0 -280
- package/resource/doc/roomkit/vue/features/room-view.md +0 -241
- package/resource/doc/roomkit/vue/integration.md +0 -315
- package/resource/doc/rtcengine/faq/web_sdk/.gitkeep +0 -0
- package/resource/doc/trtc/C++/ITXAudioEffectManager.md +0 -472
- package/resource/doc/trtc/C++/ITXDeviceManager.md +0 -388
- package/resource/doc/trtc/android/TXBeautyManager.md +0 -403
- package/resource/doc/trtc/iOS/TXBeautyManager.md +0 -404
- package/resource/doc/trtc/iOS/TXDeviceManager.md +0 -382
- package/server-config.js.map +0 -1
- package/server.js.map +0 -1
- package/streamable-http.js.map +0 -1
- package/tools/call/get_callkit_api.js +0 -33
- package/tools/call/get_callkit_api.js.map +0 -1
- package/tools/call/get_native_call_uikit_integration.js.map +0 -1
- package/tools/call/get_native_callkit_core_integration.js.map +0 -1
- package/tools/call/get_web_call_uikit_integration.js.map +0 -1
- package/tools/chat/get_native_chat_uikit_feature_detail.js +0 -35
- package/tools/chat/get_native_chat_uikit_feature_detail.js.map +0 -1
- package/tools/chat/get_native_chat_uikit_integration.js.map +0 -1
- package/tools/chat/get_web_chat_uikit_component_detail.js +0 -35
- package/tools/chat/get_web_chat_uikit_component_detail.js.map +0 -1
- package/tools/chat/get_web_chat_uikit_integration.js.map +0 -1
- package/tools/common/get_faq.js +0 -266
- package/tools/common/get_faq.js.map +0 -1
- package/tools/common/get_usersig.js.map +0 -1
- package/tools/common/present_framework_choice.js.map +0 -1
- package/tools/common/record_answer.js.map +0 -1
- package/tools/common/record_feedback.js.map +0 -1
- package/tools/common/record_skill_session.js +0 -69
- package/tools/common/record_skill_session.js.map +0 -1
- package/tools/definitions/get_callkit_api_def.js +0 -28
- package/tools/definitions/get_callkit_api_def.js.map +0 -1
- package/tools/definitions/get_faq_def.js +0 -40
- package/tools/definitions/get_faq_def.js.map +0 -1
- package/tools/definitions/get_native_call_uikit_integration_def.js.map +0 -1
- package/tools/definitions/get_native_callkit_core_integration_def.js.map +0 -1
- package/tools/definitions/get_native_chat_uikit_feature_detail_def.js +0 -31
- package/tools/definitions/get_native_chat_uikit_feature_detail_def.js.map +0 -1
- package/tools/definitions/get_native_chat_uikit_integration_def.js.map +0 -1
- package/tools/definitions/get_native_livekit_core_features_def.js +0 -33
- package/tools/definitions/get_native_livekit_core_features_def.js.map +0 -1
- package/tools/definitions/get_native_livekit_core_integration_def.js.map +0 -1
- package/tools/definitions/get_native_trtc_sdk_docs_def.js +0 -32
- package/tools/definitions/get_native_trtc_sdk_docs_def.js.map +0 -1
- package/tools/definitions/get_usersig_def.js.map +0 -1
- package/tools/definitions/get_web_call_uikit_integration_def.js.map +0 -1
- package/tools/definitions/get_web_chat_uikit_component_detail_def.js +0 -31
- package/tools/definitions/get_web_chat_uikit_component_detail_def.js.map +0 -1
- package/tools/definitions/get_web_chat_uikit_integration_def.js.map +0 -1
- package/tools/definitions/get_web_live_uikit_integration_def.js.map +0 -1
- package/tools/definitions/get_web_livekit_api_def.js +0 -27
- package/tools/definitions/get_web_livekit_api_def.js.map +0 -1
- package/tools/definitions/get_web_livekit_component_detail_def.js +0 -29
- package/tools/definitions/get_web_livekit_component_detail_def.js.map +0 -1
- package/tools/definitions/get_web_room_uikit_integration_def.js.map +0 -1
- package/tools/definitions/get_web_roomkit_feature_detail_def.js +0 -30
- package/tools/definitions/get_web_roomkit_feature_detail_def.js.map +0 -1
- package/tools/definitions/get_web_trtc_sdk_api_def.js +0 -25
- package/tools/definitions/get_web_trtc_sdk_api_def.js.map +0 -1
- package/tools/definitions/get_web_trtc_sdk_integration_def.js +0 -25
- package/tools/definitions/get_web_trtc_sdk_integration_def.js.map +0 -1
- package/tools/definitions/get_web_trtc_sdk_plugin_def.js +0 -25
- package/tools/definitions/get_web_trtc_sdk_plugin_def.js.map +0 -1
- package/tools/definitions/present_framework_choice_def.js.map +0 -1
- package/tools/definitions/record_answer_def.js.map +0 -1
- package/tools/definitions/record_feedback_def.js.map +0 -1
- package/tools/definitions/record_skill_session_def.js +0 -31
- package/tools/definitions/record_skill_session_def.js.map +0 -1
- package/tools/index.js.map +0 -1
- package/tools/live/get_native_livekit_core_features.js +0 -68
- package/tools/live/get_native_livekit_core_features.js.map +0 -1
- package/tools/live/get_native_livekit_core_integration.js.map +0 -1
- package/tools/live/get_web_live_uikit_integration.js.map +0 -1
- package/tools/live/get_web_livekit_api.js +0 -33
- package/tools/live/get_web_livekit_api.js.map +0 -1
- package/tools/live/get_web_livekit_component_detail.js +0 -35
- package/tools/live/get_web_livekit_component_detail.js.map +0 -1
- package/tools/room/get_web_room_uikit_integration.js.map +0 -1
- package/tools/room/get_web_roomkit_feature_detail.js +0 -69
- package/tools/room/get_web_roomkit_feature_detail.js.map +0 -1
- package/tools/rtcengine/get_web_trtc_sdk_api.js +0 -32
- package/tools/rtcengine/get_web_trtc_sdk_api.js.map +0 -1
- package/tools/rtcengine/get_web_trtc_sdk_integration.js +0 -32
- package/tools/rtcengine/get_web_trtc_sdk_integration.js.map +0 -1
- package/tools/rtcengine/get_web_trtc_sdk_plugin.js +0 -32
- package/tools/rtcengine/get_web_trtc_sdk_plugin.js.map +0 -1
- package/tools/trtc/get_native_trtc_sdk_docs.js +0 -74
- package/tools/trtc/get_native_trtc_sdk_docs.js.map +0 -1
- package/utils/build-session-directives.js +0 -122
- package/utils/build-session-directives.js.map +0 -1
- package/utils/generate-structured-result.js.map +0 -1
- package/utils/generate-usersig.js.map +0 -1
- package/utils/get-device-identifier.js.map +0 -1
- package/utils/get-doc-content.js.map +0 -1
- package/utils/handle-framework.js +0 -9
- package/utils/handle-framework.js.map +0 -1
- package/utils/handle-state-name.js +0 -29
- package/utils/handle-state-name.js.map +0 -1
- package/utils/http-get.js.map +0 -1
- package/utils/http-post.js.map +0 -1
- package/utils/report-cls-client.js.map +0 -1
- package/utils/report-es-client.js.map +0 -1
- package/utils/report-runtime-error-cls-client.js.map +0 -1
- /package/resource/{doc/callkit/faq/common → knowledge/callkit/faq}/error-code.md +0 -0
- /package/resource/{doc/livekit/faq/common → knowledge/livekit/faq}/error-code.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/api.md +0 -0
- /package/resource/{doc/rtcengine/faq/web/web.md → knowledge/rtcengine/web/faq.md} +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/how_to_integrated_web_sdk.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/20-advanced-customized-capture-rendering.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/28-advanced-beauty.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/29-advanced-water-mark.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/30-advanced-cross-room-link.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/34-advanced-proxy.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/35-advanced-ai-denoiser.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/36-advanced-virtual-background.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/37-advanced-voice-changer.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/38-advanced-basic-beauty.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/39-advanced-video-decoder.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/40-advanced-video-mixer.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/41-advanced-small-stream-auto-switcher.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/42-advanced-realtime-transcriber.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/43-advanced-face-detection.md +0 -0
- /package/resource/{doc/rtcengine/faq/common → knowledge/share}/userSig.md +0 -0
|
@@ -0,0 +1,1292 @@
|
|
|
1
|
+
本文档将帮助您使用 **AtomicXCore SDK** 的 **DeviceStore**、**CallStore** 以及核心组件 **CallCoreView**,快速完成拨打电话功能。
|
|
2
|
+
|
|
3
|
+
> 推荐使用更高效的 AI 集成助手
|
|
4
|
+
>
|
|
5
|
+
|
|
6
|
+
> 我们为您提供了全新的 AI 集成方式,只需要描述您的需求,即可自动生成集成代码,大幅提升开发效率。
|
|
7
|
+
>
|
|
8
|
+
|
|
9
|
+
> 点击这里,立即体验 AI 集成
|
|
10
|
+
>
|
|
11
|
+
|
|
12
|
+
## 核心功能
|
|
13
|
+
|
|
14
|
+
**AtomicXCore **中用于搭建多人音视频通话场景所需要使用到的核心模块包含以下三个:
|
|
15
|
+
|
|
16
|
+
|**模块**|**功能描述**|
|
|
17
|
+
|---------|---------|
|
|
18
|
+
|[CallCoreView](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callcoreview)|通话视图核心组件。自动监听 CallStore 数据并完成画面渲染,同时提供布局切换、头像与图标配置等 UI 定制化能力。|
|
|
19
|
+
|[CallStore](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callstore)|通话生命周期管理:拨打电话、接通电话、拒接电话、挂断电话。实时获取参与通话人员音视频状态,通话计时、通话记录等数据。|
|
|
20
|
+
|[DeviceStore](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/devicestore)|音视频设备控制:麦克风(开关 / 音量)、摄像头(开关 / 切换 / 画质)、屏幕共享,设备状态实时监听。|
|
|
21
|
+
|
|
22
|
+
## 准备工作
|
|
23
|
+
|
|
24
|
+
### 步骤1:开通服务
|
|
25
|
+
|
|
26
|
+
请参见 开通服务,获取体验版或付费版 SDK。
|
|
27
|
+
|
|
28
|
+
### 步骤2:集成 SDK
|
|
29
|
+
1. **添加 Pod 依赖:**在您项目的 `Podfile` 文件中添加 `pod 'AtomicXCore'` 依赖。
|
|
30
|
+
|
|
31
|
+
``` ruby
|
|
32
|
+
target 'YourProjectTarget' do
|
|
33
|
+
pod 'AtomicXCore'
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
> **提示:**
|
|
39
|
+
>
|
|
40
|
+
|
|
41
|
+
> **若项目没有 Podfile 文件:**在终端中进入到您的 `.xcodeproj` 目录下,然后执行 `pod init` 命令创建 `Podfile` 文件。
|
|
42
|
+
>
|
|
43
|
+
|
|
44
|
+
2. **安装组件:**在终端进入到 `Podfile` 文件所在的目录,然后执行以下命令安装组件。
|
|
45
|
+
|
|
46
|
+
``` bash
|
|
47
|
+
pod install --repo-update
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
> **提示:**
|
|
51
|
+
>
|
|
52
|
+
|
|
53
|
+
> 安装完成后,使用 `YourProjectName.xcworkspace` 文件打开项目。
|
|
54
|
+
>
|
|
55
|
+
|
|
56
|
+
### 步骤3:初始化与登录流程
|
|
57
|
+
|
|
58
|
+
启动通话服务需依次完成以下三步:
|
|
59
|
+
1. **实例化 CallStore**:`CallStore.shared` 初始化通话数据层。
|
|
60
|
+
|
|
61
|
+
2. **用户登录:**调用 `LoginStore.shared.login()` 完成用户登录。
|
|
62
|
+
|
|
63
|
+
3. **初始化通话引擎:**登录成功后调用 `TUICallEngine.createInstance().`init`()` 初始化通话信令引擎。
|
|
64
|
+
|
|
65
|
+
流程图与示例代码如下:
|
|
66
|
+
|
|
67
|
+
【iOS】
|
|
68
|
+
``` swift
|
|
69
|
+
import UIKit
|
|
70
|
+
import AtomicXCore
|
|
71
|
+
import RTCRoomEngine
|
|
72
|
+
import Combine
|
|
73
|
+
|
|
74
|
+
class ViewController: UIViewController {
|
|
75
|
+
var cancellables = Set<AnyCancellable>()
|
|
76
|
+
|
|
77
|
+
override func viewDidLoad() {
|
|
78
|
+
super.viewDidLoad()
|
|
79
|
+
// CallStore 初始化
|
|
80
|
+
let _ = CallStore.shared
|
|
81
|
+
|
|
82
|
+
// 配置您的信息
|
|
83
|
+
let userID = "test_001" // 请替换为您的 UserID
|
|
84
|
+
let sdkAppID: Int = 1400000001 // 请替换为在控制台得到的 SDKAppID
|
|
85
|
+
let secretKey = "**************" // 请替换为在控制台得到的 SecretKey
|
|
86
|
+
|
|
87
|
+
// 生成 UserSig(仅用于本地快速测试,正式环境请在服务端生成)
|
|
88
|
+
let userSig = GenerateTestUserSig.genTestUserSig(
|
|
89
|
+
userID: userID,
|
|
90
|
+
sdkAppID: sdkAppID,
|
|
91
|
+
secretKey: secretKey
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
// 登录
|
|
95
|
+
LoginStore.shared.login(
|
|
96
|
+
sdkAppID: Int32(sdkAppID),
|
|
97
|
+
userID: userID,
|
|
98
|
+
userSig: userSig
|
|
99
|
+
) { result in
|
|
100
|
+
switch result {
|
|
101
|
+
case .success:
|
|
102
|
+
Log.info("login success")
|
|
103
|
+
// 完成 TUICallEngine 的初始化
|
|
104
|
+
TUICallEngine.createInstance().`init`(Int32(sdkAppID), userId: userID, userSig: userSig) {
|
|
105
|
+
Log.info("TUICallEngine init success")
|
|
106
|
+
} fail: { code, message in
|
|
107
|
+
Log.error("TUICallEngine init failed, code: \(code), message: \(message ?? "")")
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
case .failure(let error):
|
|
111
|
+
Log.error("login failed, code: \(error.code), error: \(error.message)")
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
| <strong>参数</strong> | <strong>类型</strong> | <strong>说明</strong> |
|
|
120
|
+
| --- | --- | --- |
|
|
121
|
+
| userID | String | 当前用户的唯一 ID,仅包含英文字母、数字、连字符和下划线。为避免多端登录冲突,请勿使用 1、123 等简单 ID。 |
|
|
122
|
+
| sdkAppID | int | 从 <a href="https://console.cloud.tencent.com/trtc">控制台</a> 获取,通常是以 140 或 160 开头的 10 位整数。 |
|
|
123
|
+
| secretKey | String | 在 <a href="https://console.cloud.tencent.com/trtc">控制台</a> 创建的音视频应用的 SDKSecretKey。 |
|
|
124
|
+
| userSig | String | 用于腾讯云鉴权的票据。请注意:<br>- 开发环境:您可以采用本地 <a href="https://github.com/Tencent-RTC/TUIKit_iOS/blob/main/call/TUICallKit_Swift/Debug/GenerateTestUserSig.swift">GenerateTestUserSig.genTestUserSig</a> 函数生成 userSig 或者通过 <a href="https://console.cloud.tencent.com/im/tool-usersig">UserSig 辅助工具</a> 生成临时的 UserSig。<br>- 生产环境:为了防止密钥泄露,请务必采用服务端生成 UserSig 的方式。详细信息请参考 <a href="https://cloud.tencent.com/document/product/647/17275">服务端生成 UserSig</a>。<br>更多信息请参见 <a href="https://cloud.tencent.com/document/product/647/17275">如何计算及使用 UserSig</a>。 |
|
|
125
|
+
|
|
126
|
+
## 实现步骤
|
|
127
|
+
|
|
128
|
+
**发起通话前,请确保完成登录**,这是服务可用的必要前提。以下将分 5 步为您讲解如何"拨打一通电话"。
|
|
129
|
+
|
|
130
|
+
### 步骤1:创建通话界面
|
|
131
|
+
|
|
132
|
+
您需要创建一个通话页面,当发起通话时唤起通话页面,实现方式如下:
|
|
133
|
+
1. **创建通话页面**:您可以新建一个 UIViewController 作为通话宿主页面,用于响应来电时的跳转逻辑。
|
|
134
|
+
|
|
135
|
+
2. **通话页面绑定 **[**CallCoreView**](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callcoreview/): 通话视图核心组件,自动监听 **CallStore** 数据并完成画面渲染,同时提供布局切换、头像与图标配置等 UI 定制化能力。
|
|
136
|
+
|
|
137
|
+
【iOS】
|
|
138
|
+
``` swift
|
|
139
|
+
import UIKit
|
|
140
|
+
import AtomicXCore
|
|
141
|
+
|
|
142
|
+
class CallViewController: UIViewController {
|
|
143
|
+
// 1.创建通话页面
|
|
144
|
+
override func viewDidLoad() {
|
|
145
|
+
super.viewDidLoad()
|
|
146
|
+
view.backgroundColor = .black
|
|
147
|
+
//2.通话页面绑定 CallCoreView
|
|
148
|
+
callCoreView = CallCoreView(frame: view.bounds)
|
|
149
|
+
callCoreView?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
150
|
+
if let callCoreView = callCoreView {
|
|
151
|
+
view.addSubview(callCoreView)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**CallCoreView 视图组件功能说明:**
|
|
158
|
+
|
|
159
|
+
|**功能**|**说明**|**参考文档**|
|
|
160
|
+
|---------|---------|---------|
|
|
161
|
+
|**设置布局模式**|支持自由切换布局模式。若未设置,将根据通话人数自动适配布局。|切换布局模式|
|
|
162
|
+
|**设置头像**|支持通过传入头像资源路径,为特定用户自定义头像。|自定义默认头像|
|
|
163
|
+
|**设置音量提示图标**|支持根据不同音量等级,配置个性化的音量指示图标。|自定义音量提示的图标|
|
|
164
|
+
|**设置网络提示图标**|支持根据实时网络质量,配置对应的网络状态提示图标。|自定义网络提示的图标|
|
|
165
|
+
|**设置等待接听用户的动画**|在多人通话场景下,支持传入 GIF 图像路径,为待接听状态的用户展示动画。|步骤2:添加通话控制按钮|
|
|
166
|
+
|
|
167
|
+
### 步骤2:添加通话控制按钮
|
|
168
|
+
|
|
169
|
+
您可以参考 [**DeviceStore**](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/devicestore) 、[**CallStore**](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callstore) 提供的 API ,自定义添加您的按钮。
|
|
170
|
+
- **DeviceStore 功能说明:**麦克风(开关 / 音量)、摄像头(开关 / 切换 / 画质)、屏幕共享,设备状态实时监听。建议将对应方法绑定至按钮点击事件,并通过监听设备状态变更来实时刷新按钮的 UI 状态。
|
|
171
|
+
|
|
172
|
+
- **CallStore 功能说明:**接听、挂断、拒接等核心通话控制能力。建议将对应方法绑定至按钮点击事件,并监听通话状态的变化,以确保按钮显示与当前通话阶段保持同步。
|
|
173
|
+
|
|
174
|
+
- **图标资源下载:**按钮图标可以直接从 [GitHub](http://github.com/Tencent-RTC/TUIKit_iOS/tree/main/call/TUICallKit_Swift/Resources/Assets.xcassets) 下载。这些图标由我们的设计师专为 TUICallKit 打造,无版权风险,可放心使用。
|
|
175
|
+
|
|
176
|
+
| <strong>图标:</strong> | | | | | | | | |
|
|
177
|
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
178
|
+
|
|
179
|
+
- **以添加挂断、麦克风、摄像头按钮为例,实现方式如下:**
|
|
180
|
+
|
|
181
|
+
1. **添加挂断按钮**:创建并添加挂断按钮,在点击事件中调用 hangup 并销毁界面。
|
|
182
|
+
|
|
183
|
+
``` swift
|
|
184
|
+
import UIKit
|
|
185
|
+
import AtomicXCore
|
|
186
|
+
import Combine
|
|
187
|
+
|
|
188
|
+
class CallViewController: UIViewController {
|
|
189
|
+
private lazy var buttonHangup: UIButton = {
|
|
190
|
+
let buttonWidth: CGFloat = 80
|
|
191
|
+
let buttonHeight: CGFloat = 80
|
|
192
|
+
let spacing: CGFloat = 30
|
|
193
|
+
let bottomMargin: CGFloat = 80
|
|
194
|
+
|
|
195
|
+
let totalWidth = buttonWidth * 3 + spacing * 2
|
|
196
|
+
let startX = (view.bounds.width - totalWidth) / 2
|
|
197
|
+
let buttonY = view.bounds.height - bottomMargin - buttonHeight
|
|
198
|
+
|
|
199
|
+
let button = createButton(
|
|
200
|
+
frame: CGRect(x: startX + (buttonWidth + spacing) * 2, y: buttonY, width: buttonWidth, height: buttonHeight),
|
|
201
|
+
title: "挂断"
|
|
202
|
+
)
|
|
203
|
+
button.backgroundColor = .systemRed
|
|
204
|
+
button.addTarget(self, action: #selector(touchHangupButton), for: .touchUpInside)
|
|
205
|
+
return button
|
|
206
|
+
}()
|
|
207
|
+
|
|
208
|
+
override func viewDidLoad() {
|
|
209
|
+
super.viewDidLoad()
|
|
210
|
+
// 其他初始化代码
|
|
211
|
+
// 1.添加挂断按钮
|
|
212
|
+
view.addSubview(buttonHangup)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
@objc private func touchHangupButton() {
|
|
216
|
+
// 2.在点击事件中调用 hangup 接口并销毁页面
|
|
217
|
+
CallStore.shared.hangup(completion: nil)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
private func createButton(frame: CGRect, title: String) -> UIButton {
|
|
221
|
+
let button = UIButton(type: .system)
|
|
222
|
+
button.frame = frame
|
|
223
|
+
button.setTitle(title, for: .normal)
|
|
224
|
+
button.setTitleColor(.white, for: .normal)
|
|
225
|
+
button.backgroundColor = UIColor(white: 0.3, alpha: 0.8)
|
|
226
|
+
button.layer.cornerRadius = frame.width / 2
|
|
227
|
+
button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
|
|
228
|
+
return button
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
2. **添加麦克风开关按钮:**创建并添加麦克风开关按钮,并在点击事件中调用 [openLocalMicrophone](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/devicestore/openlocalmicrophone(completion:)) 或 [closeLocalMicrophone](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/devicestore/closelocalmicrophone()) 接口。
|
|
233
|
+
|
|
234
|
+
``` swift
|
|
235
|
+
import UIKit
|
|
236
|
+
import AtomicXCore
|
|
237
|
+
import Combine
|
|
238
|
+
|
|
239
|
+
class CallViewController: UIViewController {
|
|
240
|
+
private lazy var buttonMicrophone: UIButton = {
|
|
241
|
+
let buttonWidth: CGFloat = 80
|
|
242
|
+
let buttonHeight: CGFloat = 80
|
|
243
|
+
let spacing: CGFloat = 30
|
|
244
|
+
let bottomMargin: CGFloat = 80
|
|
245
|
+
let totalWidth = buttonWidth * 3 + spacing * 2
|
|
246
|
+
let startX = (view.bounds.width - totalWidth) / 2
|
|
247
|
+
let buttonY = view.bounds.height - bottomMargin - buttonHeight
|
|
248
|
+
|
|
249
|
+
let button = createButton(
|
|
250
|
+
frame: CGRect(x: startX + buttonWidth + spacing, y: buttonY, width: buttonWidth, height: buttonHeight),
|
|
251
|
+
title: "麦克风"
|
|
252
|
+
)
|
|
253
|
+
button.addTarget(self, action: #selector(touchMicrophoneButton), for: .touchUpInside)
|
|
254
|
+
return button
|
|
255
|
+
}()
|
|
256
|
+
|
|
257
|
+
override func viewDidLoad() {
|
|
258
|
+
super.viewDidLoad()
|
|
259
|
+
// 其他初始化代码
|
|
260
|
+
// 1.添加麦克风开关按钮
|
|
261
|
+
view.addSubview(buttonMicrophone)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// 2.点击事件调用开启或关闭麦克风
|
|
265
|
+
@objc private func touchMicrophoneButton() {
|
|
266
|
+
let microphoneStatus = DeviceStore.shared.state.value.microphoneStatus
|
|
267
|
+
if microphoneStatus == .on {
|
|
268
|
+
DeviceStore.shared.closeLocalMicrophone()
|
|
269
|
+
} else {
|
|
270
|
+
DeviceStore.shared.openLocalMicrophone(completion: nil)
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// 创建圆形按钮辅助方法
|
|
275
|
+
private func createButton(frame: CGRect, title: String) -> UIButton {
|
|
276
|
+
let button = UIButton(type: .system)
|
|
277
|
+
button.frame = frame
|
|
278
|
+
button.setTitle(title, for: .normal)
|
|
279
|
+
button.setTitleColor(.white, for: .normal)
|
|
280
|
+
button.backgroundColor = UIColor(white: 0.3, alpha: 0.8)
|
|
281
|
+
button.layer.cornerRadius = frame.width / 2
|
|
282
|
+
button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
|
|
283
|
+
return button
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
3. **添加摄像头开关按钮:**在底部工具栏容器中添加摄像头开关按钮,并在点击事件中调用 [openLocalCamera](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/devicestore/openlocalcamera(isfront:completion:)) 或 [closeLocalCamera](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/devicestore/closelocalcamera()) 接口。
|
|
288
|
+
|
|
289
|
+
``` swift
|
|
290
|
+
import UIKit
|
|
291
|
+
import AtomicXCore
|
|
292
|
+
import Combine
|
|
293
|
+
|
|
294
|
+
class CallViewController: UIViewController {
|
|
295
|
+
private lazy var buttonCamera: UIButton = {
|
|
296
|
+
let buttonWidth: CGFloat = 80
|
|
297
|
+
let buttonHeight: CGFloat = 80
|
|
298
|
+
let spacing: CGFloat = 30
|
|
299
|
+
let bottomMargin: CGFloat = 80
|
|
300
|
+
let totalWidth = buttonWidth * 3 + spacing * 2
|
|
301
|
+
let startX = (view.bounds.width - totalWidth) / 2
|
|
302
|
+
let buttonY = view.bounds.height - bottomMargin - buttonHeight
|
|
303
|
+
|
|
304
|
+
let button = createButton(
|
|
305
|
+
frame: CGRect(x: startX, y: buttonY, width: buttonWidth, height: buttonHeight),
|
|
306
|
+
title: "摄像头"
|
|
307
|
+
)
|
|
308
|
+
button.addTarget(self, action: #selector(touchCameraButton), for: .touchUpInside)
|
|
309
|
+
return button
|
|
310
|
+
}()
|
|
311
|
+
|
|
312
|
+
override func viewDidLoad() {
|
|
313
|
+
super.viewDidLoad()
|
|
314
|
+
// 其他初始化代码
|
|
315
|
+
// 1.添加摄像头开关按钮
|
|
316
|
+
view.addSubview(buttonCamera)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// 2.摄像头按钮点击事件
|
|
320
|
+
@objc private func touchCameraButton() {
|
|
321
|
+
let cameraStatus = DeviceStore.shared.state.value.cameraStatus
|
|
322
|
+
if cameraStatus == .on {
|
|
323
|
+
DeviceStore.shared.closeLocalCamera()
|
|
324
|
+
} else {
|
|
325
|
+
let isFront = DeviceStore.shared.state.value.isFrontCamera
|
|
326
|
+
DeviceStore.shared.openLocalCamera(isFront: isFront, completion: nil)
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// 创建圆形按钮辅助方法
|
|
331
|
+
private func createButton(frame: CGRect, title: String) -> UIButton {
|
|
332
|
+
let button = UIButton(type: .system)
|
|
333
|
+
button.frame = frame
|
|
334
|
+
button.setTitle(title, for: .normal)
|
|
335
|
+
button.setTitleColor(.white, for: .normal)
|
|
336
|
+
button.backgroundColor = UIColor(white: 0.3, alpha: 0.8)
|
|
337
|
+
button.layer.cornerRadius = frame.width / 2
|
|
338
|
+
button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
|
|
339
|
+
return button
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
4. **实时更新媒体设备按钮文本:**监听麦克风和摄像头的状态,实时更新按钮文本。
|
|
344
|
+
|
|
345
|
+
``` swift
|
|
346
|
+
import UIKit
|
|
347
|
+
import AtomicXCore
|
|
348
|
+
import Combine
|
|
349
|
+
|
|
350
|
+
class CallViewController: UIViewController {
|
|
351
|
+
private var cancellables = Set<AnyCancellable>()
|
|
352
|
+
|
|
353
|
+
override func viewDidLoad() {
|
|
354
|
+
super.viewDidLoad()
|
|
355
|
+
// 其他初始化代码
|
|
356
|
+
// 1.监听麦克风和摄像头的状态
|
|
357
|
+
observeDeviceState()
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
private func observeDeviceState() {
|
|
361
|
+
DeviceStore.shared.state.subscribe()
|
|
362
|
+
.map { $0.cameraStatus }
|
|
363
|
+
.removeDuplicates()
|
|
364
|
+
.receive(on: DispatchQueue.main)
|
|
365
|
+
.sink {
|
|
366
|
+
// 2.更新摄像头按钮文本
|
|
367
|
+
[weak self] cameraStatus in
|
|
368
|
+
let title = cameraStatus == .on ? "关闭摄像头" : "开启摄像头"
|
|
369
|
+
self?.buttonCamera?.setTitle(title, for: .normal)
|
|
370
|
+
}
|
|
371
|
+
.store(in: &cancellables)
|
|
372
|
+
|
|
373
|
+
DeviceStore.shared.state.subscribe()
|
|
374
|
+
.map { $0.microphoneStatus }
|
|
375
|
+
.removeDuplicates()
|
|
376
|
+
.receive(on: DispatchQueue.main)
|
|
377
|
+
.sink {
|
|
378
|
+
// 2.更新麦克风按钮文本
|
|
379
|
+
[weak self] microphoneStatus in
|
|
380
|
+
let title = microphoneStatus == .on ? "关闭麦克风" : "开启麦克风"
|
|
381
|
+
self?.buttonMicrophone?.setTitle(title, for: .normal)
|
|
382
|
+
}
|
|
383
|
+
.store(in: &cancellables)
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### 步骤3:申请麦克风/摄像头权限
|
|
389
|
+
|
|
390
|
+
建议在发起通话前,先行检测音视频权限。若权限缺失,请引导用户动态申请。实现方法如下:
|
|
391
|
+
1. **声明权限:**请在应用的 `Info.plist` 文件中添加以下两项,并填写对应的使用说明,这些说明将在系统请求权限时向用户显示:
|
|
392
|
+
|
|
393
|
+
``` swift
|
|
394
|
+
<key>NSCameraUsageDescription</key>
|
|
395
|
+
<string>需要访问您的摄像头,并可用于视频通话、群组视频通话等功能</string>
|
|
396
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
397
|
+
<string>需要访问您的麦克风,并可用于音频通话、群组音频通话、视频通话、群组视频通话等功能</string>
|
|
398
|
+
```
|
|
399
|
+
2. **动态申请权限:**我们推荐您在发起通话时,根据通话媒体类型动态申请音视频权限。以下是权限处理的示例代码:
|
|
400
|
+
|
|
401
|
+
``` swift
|
|
402
|
+
|
|
403
|
+
import AVFoundation
|
|
404
|
+
import UIKit
|
|
405
|
+
|
|
406
|
+
extension UIViewController {
|
|
407
|
+
|
|
408
|
+
// 检查麦克风权限
|
|
409
|
+
func checkMicrophonePermission(completion: @escaping (Bool) -> Void) {
|
|
410
|
+
let status = AVCaptureDevice.authorizationStatus(for: .audio)
|
|
411
|
+
|
|
412
|
+
switch status {
|
|
413
|
+
case .authorized:
|
|
414
|
+
completion(true)
|
|
415
|
+
|
|
416
|
+
case .notDetermined:
|
|
417
|
+
AVCaptureDevice.requestAccess(for: .audio) { granted in
|
|
418
|
+
DispatchQueue.main.async {
|
|
419
|
+
completion(granted)
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
case .denied, .restricted:
|
|
424
|
+
completion(false)
|
|
425
|
+
|
|
426
|
+
@unknown default:
|
|
427
|
+
completion(false)
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// 检查摄像头权限
|
|
432
|
+
func checkCameraPermission(completion: @escaping (Bool) -> Void) {
|
|
433
|
+
let status = AVCaptureDevice.authorizationStatus(for: .video)
|
|
434
|
+
|
|
435
|
+
switch status {
|
|
436
|
+
case .authorized:
|
|
437
|
+
completion(true)
|
|
438
|
+
|
|
439
|
+
case .notDetermined:
|
|
440
|
+
AVCaptureDevice.requestAccess(for: .video) { granted in
|
|
441
|
+
DispatchQueue.main.async {
|
|
442
|
+
completion(granted)
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
case .denied, .restricted:
|
|
447
|
+
completion(false)
|
|
448
|
+
|
|
449
|
+
@unknown default:
|
|
450
|
+
completion(false)
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// 显示权限提示
|
|
455
|
+
func showPermissionAlert(message: String) {
|
|
456
|
+
let alert = UIAlertController(
|
|
457
|
+
title: "权限请求",
|
|
458
|
+
message: message,
|
|
459
|
+
preferredStyle: .alert
|
|
460
|
+
)
|
|
461
|
+
|
|
462
|
+
alert.addAction(UIAlertAction(title: "去设置", style: .default) { _ in
|
|
463
|
+
if let url = URL(string: UIApplication.openSettingsURLString) {
|
|
464
|
+
UIApplication.shared.open(url)
|
|
465
|
+
}
|
|
466
|
+
})
|
|
467
|
+
|
|
468
|
+
alert.addAction(UIAlertAction(title: "取消", style: .cancel))
|
|
469
|
+
present(alert, animated: true)
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### 步骤4:发起通话
|
|
475
|
+
|
|
476
|
+
您可以在 [calls](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callstore/calls(participantids:callmediatype:params:completion:)) 调用成功后跳转通话界面,我们建议您根据媒体类型自动开启麦克风或摄像头获得更好的通话体验,实现方式如下:
|
|
477
|
+
1. **发起通话:**调用 `calls` 发起通话。
|
|
478
|
+
|
|
479
|
+
2. **开启媒体设备:**发起通话成功后开启麦克风,如果是视频通话同时开启摄像头。
|
|
480
|
+
|
|
481
|
+
3. **唤起通话页面:**发起通话成功,唤起通话页面。
|
|
482
|
+
|
|
483
|
+
``` swift
|
|
484
|
+
import UIKit
|
|
485
|
+
import AtomicXCore
|
|
486
|
+
import Combine
|
|
487
|
+
|
|
488
|
+
class MainViewController: UIViewController {
|
|
489
|
+
// 1.发起通话
|
|
490
|
+
private func startCall(userIdList: [String], mediaType: CallMediaType) {
|
|
491
|
+
var params = CallParams()
|
|
492
|
+
params.timeout = 30 // 设置通话超时时间为30秒
|
|
493
|
+
|
|
494
|
+
CallStore.shared.calls(
|
|
495
|
+
participantIds: userIdList,
|
|
496
|
+
mediaType: mediaType, // 通话类型:.audio(音频) 或 .video(视频)
|
|
497
|
+
params: params
|
|
498
|
+
) { [weak self] result in
|
|
499
|
+
switch result {
|
|
500
|
+
case .success:
|
|
501
|
+
// 2.开启媒体设备
|
|
502
|
+
self?.openDevices(for: mediaType)
|
|
503
|
+
// 3.唤起通话页面
|
|
504
|
+
DispatchQueue.main.async {
|
|
505
|
+
let callVC = CallViewController()
|
|
506
|
+
callVC.modalPresentationStyle = .fullScreen
|
|
507
|
+
self?.present(callVC, animated: true)
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
case .failure(let error):
|
|
511
|
+
Log.error("发起通话失败: \(error)")
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
private func openDevices(for mediaType: CallMediaType) {
|
|
517
|
+
DeviceStore.shared.openLocalMicrophone(completion: nil)
|
|
518
|
+
if mediaType == .video {
|
|
519
|
+
let isFront = DeviceStore.shared.state.value.isFrontCamera
|
|
520
|
+
DeviceStore.shared.openLocalCamera(isFront: isFront, completion: nil)
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
**calls 接口参数详细说明:**
|
|
528
|
+
|
|
529
|
+
| <strong>参数</strong> | <strong>类型</strong> | <strong>是否必填</strong> | <strong>说明</strong> |
|
|
530
|
+
| --- | --- | --- | --- |
|
|
531
|
+
| participantIds | List<String> | 是 | 目标用户的 <code>userId</code> 列表。 |
|
|
532
|
+
| mediaType | <a href="https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callmediatype">CallMediaType</a> | 是 | 通话媒体类型,用于指定发起音频通话还是视频通话。<br>- <code>CallMediaType.video</code> : 视频通话。<br>- <code>CallMediaType.audio</code> : 语音通话。 |
|
|
533
|
+
| params | <a href="https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callparams">CallParams</a> | 否 | 通话扩展参数,如:房间号、通话邀请超时时间等。<br>- <code>roomId</code> (String) : 房间 ID,可选参数,未指定时由服务端自动分配。<br>- <code>timeout</code> (Int) : 呼叫超时时间(秒)。<br>- <code>userData</code> (String) : 用户自定义数据。<br>- <code>chatGroupId</code> (String) : Chat 群组 ID,用于群组通话场景。<br>- <code>isEphemeralCall</code> (Boolean) : 是否为加密通话(不产生通话记录)。 |
|
|
534
|
+
|
|
535
|
+
### 步骤5:结束通话
|
|
536
|
+
|
|
537
|
+
无论您调用 [hangup](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callstore/hangup(completion:)) 挂断还是对方主动结束通话,均会触发 [onCallEnded](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callevent/oncallended(callid:mediatype:reason:userid:)) 事件。 建议监听该事件,当该事件被触发(即通话结束)时,执行关闭当前界面的操作。实现方式如下:
|
|
538
|
+
1. **监听通话结束事件**:监听 `onCallEnded` 事件。
|
|
539
|
+
|
|
540
|
+
2. **销毁通话页面**:`onCallEnded` 触发后,销毁通话页面。
|
|
541
|
+
|
|
542
|
+
``` swift
|
|
543
|
+
import UIKit
|
|
544
|
+
import AtomicXCore
|
|
545
|
+
import Combine
|
|
546
|
+
|
|
547
|
+
class CallViewController: UIViewController {
|
|
548
|
+
override func viewDidLoad() {
|
|
549
|
+
super.viewDidLoad()
|
|
550
|
+
// 其他初始化代码
|
|
551
|
+
|
|
552
|
+
// 1.添加通话事件监听
|
|
553
|
+
addListener()
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
private func addListener() {
|
|
557
|
+
CallStore.shared.callEventPublisher
|
|
558
|
+
.receive(on: DispatchQueue.main)
|
|
559
|
+
.sink { [weak self] event in
|
|
560
|
+
if case .onCallEnded = event {
|
|
561
|
+
// 2.销毁通话页面
|
|
562
|
+
self?.dismiss(animated: true)
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
.store(in: &cancellables)
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
**onCallEnded 事件参数详细说明**:
|
|
571
|
+
|
|
572
|
+
| <strong>参数</strong> | <strong>类型</strong> | <strong>说明</strong> |
|
|
573
|
+
| --- | --- | --- |
|
|
574
|
+
| callId | String | 此次通话的唯一标识。 |
|
|
575
|
+
| mediaType | <a href="https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callmediatype">CallMediaType</a> | 通话媒体类型,用于指定发起音频通话还是视频通话。<br>- <code>CallMediaType.video</code> : 视频通话。<br>- <code>CallMediaType.audio</code> : 语音通话。 |
|
|
576
|
+
| reason | <a href="https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callendreason">CallEndReason</a> | 通话结束的原因。<br>- <code>unknown</code> : 未知原因,无法确定结束原因。<br>- <code>hangup</code> : 正常挂断,用户主动挂断通话。<br>- <code>reject</code> : 拒绝接听,被叫方拒绝来电。<br>- <code>noResponse</code> : 无响应,被叫方未在超时时间内接听。<br>- <code>offline</code> : 对方离线,被叫方不在线。<br>- <code>lineBusy</code> : 对方忙线,被叫方正在通话中。<br>- <code>canceled</code> : 通话取消,主叫方在对方接听前取消。<br>- <code>otherDeviceAccepted</code> : 其他设备已接听,通话已在另一登录设备上接听。<br>- <code>otherDeviceReject</code> : 其他设备已拒绝,通话已在另一登录设备上拒绝。<br>- <code>endByServer</code> : 服务器结束,通话被服务器终止。 |
|
|
577
|
+
| userId | String | 触发结束的用户 ID。 |
|
|
578
|
+
|
|
579
|
+
### 运行效果
|
|
580
|
+
|
|
581
|
+
当您完成以上 5 步后,"拨打一通电话"运行效果如下:
|
|
582
|
+
|
|
583
|
+
## 定制页面
|
|
584
|
+
|
|
585
|
+
**CallCoreView** 提供了完善的 UI 定制能力,支持头像及音量提示等图标的自由替换。**为助力快速集成,您可以直接从 **[**GitHub**](http://github.com/Tencent-RTC/TUIKit_iOS/tree/main/call/TUICallKit_Swift/Resources/Assets.xcassets)**下载。这些图标由我们的设计师专为 TUICallKit 打造,无版权风险,可放心使用。**
|
|
586
|
+
|
|
587
|
+
### 自定义音量提示的图标
|
|
588
|
+
|
|
589
|
+
您可以调用 **CallCoreView** 组件的 [setVolumeLevelIcons](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callcoreview/setvolumelevelicons(icons:)) 设置音量大小等级不同的提示图标。
|
|
590
|
+
|
|
591
|
+
- **setVolumeLevelIcons****示例代码:**
|
|
592
|
+
|
|
593
|
+
【iOS】
|
|
594
|
+
``` swift
|
|
595
|
+
// 设置音量提示图标
|
|
596
|
+
let volumeLevelIcons: [VolumeLevel: String] = [
|
|
597
|
+
.mute: "对应图标资源的路径"
|
|
598
|
+
]
|
|
599
|
+
callCoreView.setVolumeLevelIcons(icons: volumeLevelIcons)
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
- **setVolumeLevelIcons 接口参数详细说明:**
|
|
603
|
+
|
|
604
|
+
| <strong>参数</strong> | <strong>类型</strong> | <strong>是否必填</strong> | <strong>说明</strong> |
|
|
605
|
+
| --- | --- | --- | --- |
|
|
606
|
+
| icons | [VolumeLevel: String] | 是 | 音量等级与图标资源的映射表。字典结构说明如下:<br>key ( VolumeLevel ) 表示音量等级:<br>- <code>VolumeLevel.mute</code> :表示麦克风关闭,静音状态。<br>- <code>VolumeLevel.low</code> :表示音量范围 (0-25]。<br>- <code>VolumeLevel.medium</code> : 表示音量范围 (25-50]。<br>- <code>VolumeLevel.high</code> : 表示音量范围 (50-75]。<br>- <code>VolumeLevel.peak</code> : 表示音量范围 (75-100]。<br>Value ( String ) 表示对应音量等级的图标资源路径。 |
|
|
607
|
+
|
|
608
|
+
- **音量提示图标:**
|
|
609
|
+
|
|
610
|
+
| <strong>图标</strong> | <strong>说明</strong> |
|
|
611
|
+
| --- | --- |
|
|
612
|
+
| | 【图标含义】音量提示图标。<br>【推荐用法】您可以将该图标等级设置为 <code>VolumeLevel.low</code> 或 <code>VolumeLevel.medium</code> ,当用户音量大于对应等级时显示。 |
|
|
613
|
+
| | 【图标含义】静音图标。<br>【推荐用法】您可以将该图标等级设置为 <code>VolumeLevel.mute</code> ,当该用户静音时显示。 |
|
|
614
|
+
|
|
615
|
+
### 自定义网络提示的图标
|
|
616
|
+
|
|
617
|
+
您可以调用 **CallCoreView** 组件的 [setNetworkQualityIcons](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callcoreview/setnetworkqualityicons(icons:)) 设置不同网络状态的提示图标。
|
|
618
|
+
|
|
619
|
+
- **setNetworkQualityIcons 示例代码:**
|
|
620
|
+
|
|
621
|
+
【iOS】
|
|
622
|
+
``` swift
|
|
623
|
+
// 设置网络质量图标
|
|
624
|
+
let networkQualityIcons: [NetworkQuality: String] = [
|
|
625
|
+
.bad: "对应图标的路径"
|
|
626
|
+
]
|
|
627
|
+
callCoreView.setNetworkQualityIcons(icons: networkQualityIcons)
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
- **setNetworkQualityIcons****接口参数详细说明:**
|
|
631
|
+
|
|
632
|
+
| <strong>参数</strong> | <strong>类型</strong> | <strong>是否必填</strong> | <strong>说明</strong> |
|
|
633
|
+
| --- | --- | --- | --- |
|
|
634
|
+
| icons | [NetworkQuality: String] | 是 | 网络质量与图标资源的映射表。字典结构说明如下:<br>Key ( NetworkQuality ) : 表示网络质量等级。<br><code>NetworkQuality.unknown</code> :未知网络状态。<br><code>NetworkQuality.excellent</code>:网络状态极佳。<br><code>NetworkQuality.good</code> : 网络状态较好。<br><code>NetworkQuality.poor</code> : 网络状态较差。<br><code>NetworkQuality.bad</code> : 网络状态差。<br><code>NetworkQuality.veryBad</code> :网络状态极差。<br><code>NetworkQuality.down</code> :网络断开。<br>Value ( String ) : 对应网络状态的图标资源路径。 |
|
|
635
|
+
|
|
636
|
+
- **网络较差的提示图标:**
|
|
637
|
+
|
|
638
|
+
| <strong>图标</strong> | <strong>说明</strong> |
|
|
639
|
+
| --- | --- |
|
|
640
|
+
| | 【图标含义】网络较差的提示图标。<br>【推荐用法】您可以将该图标等级设置为 <code>NetworkQuality.bad</code>、<code>NetworkQuality.veryBad</code> 或 <code>NetworkQuality.down</code> ,当网络较差时显示该图标。 |
|
|
641
|
+
|
|
642
|
+
### 自定义默认头像
|
|
643
|
+
|
|
644
|
+
您可以调用 **CallCoreView** 的 [setParticipantAvatars](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callcoreview/setparticipantavatars(avatars:)) 接口设置用户头像。建议您监听响应式数据 [allParticipants](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callstate/allparticipants)(所有参与通话的成员):当获取到用户头像时设置并展示;若用户未设置头像或加载失败,则显示默认头像(占位图)。
|
|
645
|
+
- **setParticipantAvatars****示例代码:**
|
|
646
|
+
|
|
647
|
+
【iOS】
|
|
648
|
+
``` swift
|
|
649
|
+
// 设置用户头像
|
|
650
|
+
var avatars: [String: String] = [:]
|
|
651
|
+
let userId = "" // 用户 ID
|
|
652
|
+
let avatarPath = "" // 用户默认头像资源的路径
|
|
653
|
+
avatars[userId] = avatarPath
|
|
654
|
+
|
|
655
|
+
callCoreView.setParticipantAvatars(avatars: avatars)
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
- **setParticipantAvatars****接口参数详细说明:**
|
|
659
|
+
|
|
660
|
+
| <strong>参数</strong> | <strong>类型</strong> | <strong>是否必填</strong> | <strong>说明</strong> |
|
|
661
|
+
| --- | --- | --- | --- |
|
|
662
|
+
| avatars | [String: String] | 是 | 用户头像映射表。字典结构说明如下:<br>- Key : 用户的 userID。<br>- Value : 该用户的头像资源绝对路径。 |
|
|
663
|
+
|
|
664
|
+
- **默认头像资源:**
|
|
665
|
+
|
|
666
|
+
| <strong>图标</strong> | <strong>说明</strong> |
|
|
667
|
+
| --- | --- |
|
|
668
|
+
| | 【图标含义】默认头像。<br>【推荐用法】当用户头像加载失败或无头像时,您可以给该用户设置此默认头像。 |
|
|
669
|
+
|
|
670
|
+
### 自定义 loading 动画
|
|
671
|
+
|
|
672
|
+
您可以调用 **CallCoreView** 的 [setWaitingAnimation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callcoreview/setwaitinganimation(path:)) 接口,为等待中用户设置等待动画获得更好的体验。
|
|
673
|
+
|
|
674
|
+
- **setWaitingAnimation 示例代码:**
|
|
675
|
+
|
|
676
|
+
【iOS】
|
|
677
|
+
``` swift
|
|
678
|
+
// 设置等待动画
|
|
679
|
+
let waitingAnimationPath = "" // 等待动画 GIF 图像资源的路径
|
|
680
|
+
callCoreView.setWaitingAnimation(path: waitingAnimationPath)
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
- **setWaitingAnimation 接口参数详细说明:**
|
|
684
|
+
|
|
685
|
+
|**参数**|**类型**|**是否必填**|**说明**|
|
|
686
|
+
|---------|---------|---------|---------|
|
|
687
|
+
|path|String|是|GIF 格式图像资源的绝对路径。|
|
|
688
|
+
|
|
689
|
+
- **等待接听的动画:**
|
|
690
|
+
|
|
691
|
+
| <strong>图标</strong> | <strong>说明</strong> |
|
|
692
|
+
| --- | --- |
|
|
693
|
+
| | 【图标含义】用户等待接听动画<br>【推荐用法】群组通话时设置的动画。设置后,当用户的状态为等待接听时,显示该动画。 |
|
|
694
|
+
|
|
695
|
+
### 添加通话计时提示
|
|
696
|
+
|
|
697
|
+
通话计时可通过响应式数据 [activeCall](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callstate/activecall) 的 `duration` 字段实时获得,实时显示通话计时的实现方式如下:
|
|
698
|
+
1. **数据层订阅:**订阅 `CallStore.observerState.activeCall` , 建立当前活跃通话的响应式监听。
|
|
699
|
+
|
|
700
|
+
2. **绑定通话计时数据**:将 `activeCall.duration` 字段绑定至 UI 控件。该字段为响应式数据,会自动驱动 UI 实时刷新,无需手动维护定时器。
|
|
701
|
+
|
|
702
|
+
``` swift
|
|
703
|
+
import UIKit
|
|
704
|
+
import AtomicXCore
|
|
705
|
+
import Combine
|
|
706
|
+
|
|
707
|
+
class TimerView: UILabel {
|
|
708
|
+
private var cancellables = Set<AnyCancellable>()
|
|
709
|
+
|
|
710
|
+
override init(frame: CGRect) {
|
|
711
|
+
super.init(frame: frame)
|
|
712
|
+
setupView()
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
required init?(coder: NSCoder) {
|
|
716
|
+
super.init(coder: coder)
|
|
717
|
+
setupView()
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
private func setupView() {
|
|
721
|
+
textColor = .white
|
|
722
|
+
textAlignment = .center
|
|
723
|
+
font = .systemFont(ofSize: 16)
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
override func didMoveToWindow() {
|
|
727
|
+
super.didMoveToWindow()
|
|
728
|
+
if window != nil {
|
|
729
|
+
// 1.数据层订阅
|
|
730
|
+
registerActiveCallObserver()
|
|
731
|
+
} else {
|
|
732
|
+
cancellables.removeAll()
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
private func registerActiveCallObserver() {
|
|
737
|
+
CallStore.shared.state.subscribe()
|
|
738
|
+
.map { $0.activeCall }
|
|
739
|
+
.removeDuplicates { $0.duration == $1.duration }
|
|
740
|
+
.receive(on: DispatchQueue.main)
|
|
741
|
+
.sink { [weak self] activeCall in
|
|
742
|
+
// 更新通话计时
|
|
743
|
+
self?.updateDurationView(activeCall: activeCall)
|
|
744
|
+
}
|
|
745
|
+
.store(in: &cancellables)
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
private func updateDurationView(activeCall: CallInfo) {
|
|
749
|
+
let currentDuration = Int(activeCall.duration)
|
|
750
|
+
let minutes = currentDuration / 60
|
|
751
|
+
let seconds = currentDuration % 60
|
|
752
|
+
text = String(format: "%02d:%02d", minutes, seconds)
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
> **说明:**
|
|
758
|
+
>
|
|
759
|
+
|
|
760
|
+
> 若您想了解更多通话状态响应式数据,详细可参考:[CallState](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callstate)。
|
|
761
|
+
>
|
|
762
|
+
|
|
763
|
+
## 更多功能
|
|
764
|
+
|
|
765
|
+
### 自定义用户头像/昵称
|
|
766
|
+
|
|
767
|
+
通话开始前,您可以通过 [setSelfInfo](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/loginstore/setselfinfo(userprofile:completion:)) 方法,设置自己的昵称和头像。
|
|
768
|
+
- **setSelfInfo 示例代码**:
|
|
769
|
+
|
|
770
|
+
``` swift
|
|
771
|
+
var userProfile = UserProfile()
|
|
772
|
+
userProfile.userID = "" // 您的 userId
|
|
773
|
+
userProfile.avatarURL = "" // 头像的 url
|
|
774
|
+
userProfile.nickname = "" // 需要设置的昵称
|
|
775
|
+
|
|
776
|
+
LoginStore.shared.setSelfInfo(userProfile: userProfile) { result in
|
|
777
|
+
switch result {
|
|
778
|
+
case .success:
|
|
779
|
+
// 设置成功回调
|
|
780
|
+
case .failure(let error):
|
|
781
|
+
// 设置失败回调
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
```
|
|
785
|
+
- **setSelfInfo 接口参数详细说明:**
|
|
786
|
+
|
|
787
|
+
| <strong>参数</strong> | <strong>类型</strong> | <strong>是否必填</strong> | <strong>说明</strong> |
|
|
788
|
+
| --- | --- | --- | --- |
|
|
789
|
+
| userProfile | <a href="https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/userprofile">UserProfile</a> | 是 | 用户信息结构体:<br>- <code>userID</code> :用户的 ID<br>- <code>avatarURL</code> : 用户头像的 URL<br>- <code>nickname</code> :用户的昵称<br>更多字段详情可参考 <a href="https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/userprofile">UserProfile</a>。 |
|
|
790
|
+
|
|
791
|
+
### 切换布局模式
|
|
792
|
+
|
|
793
|
+
**CallCoreView** 内置三种布局模式,您可以调用 [setLayoutTemplate](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callcoreview/setlayouttemplate(_:)) 设置布局模式。若未主动配置,**CallCoreView** 将根据通话人数自动适配:1v1 场景下默认采用 `Float` 模式,多人通话场景下则自动切换为 `Grid` 模式。不同布局模式的说明如下:
|
|
794
|
+
| <strong>Float 模式</strong> | <strong>Grid 模式</strong> | <strong>PIP 模式</strong> |
|
|
795
|
+
| --- | --- | --- |
|
|
796
|
+
| | | |
|
|
797
|
+
| - <strong>布局逻辑:</strong>呼叫等待时全屏显示己方画面;接通后全屏显示对方画面,己方画面以悬浮小窗展示。<br>- <strong>交互特性:</strong>支持小窗拖拽移动,点击小窗可实现大小画面互换。 | - <strong>布局逻辑:</strong>所有成员画面呈网格状平铺排列成宫格模式布局,适用 2 人以上通话,支持点击放大画面功能。<br>- <strong>交互特性:</strong>支持点击特定成员画面放大查看。 | - <strong>布局逻辑:</strong>1 v 1 场景固定显示对方画面,多人场景:采用当前发言者(Active Speaker) 策略,自动识别并全屏展示正在说话的用户。<br>- <strong>交互特性:</strong>等待时显示自己的画面,接通后还会显示通话计时。 |
|
|
798
|
+
|
|
799
|
+
- **setLayoutTemplate 示例代码:**
|
|
800
|
+
|
|
801
|
+
``` swift
|
|
802
|
+
func setLayoutTemplate(_ template: CallLayoutTemplate)
|
|
803
|
+
```
|
|
804
|
+
- **setLayoutTemplate 接口参数详细说明:**
|
|
805
|
+
|
|
806
|
+
| <strong>参数</strong> | <strong>类型</strong> | <strong>说明</strong> |
|
|
807
|
+
| --- | --- | --- |
|
|
808
|
+
| template | <a href="https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/calllayouttemplate">CallLayoutTemplate</a> | CallCoreView 的布局模式<br>- <code>CallLayoutTemplate.float</code> :<br>- 布局逻辑:呼叫等待时全屏显示己方画面;接通后全屏显示对方画面,己方画面以悬浮小窗展示。<br>- 交互特性:支持小窗拖拽移动,点击小窗可实现大小画面互换。<br>- <code>CallLayoutTemplate.grid</code> :<br>- 布局逻辑:所有成员画面呈网格状平铺排列成宫格模式布局,适用 2 人以上通话,支持点击放大画面功能。<br>- 交互特性:支持点击特定成员画面放大查看。<br>- <code>CallLayoutTemplate.pip</code> :<br>- 布局逻辑:1v1 场景固定显示对方画面,多人场景:采用当前发言者(Active Speaker) 策略,自动识别并全屏展示正在说话的用户。<br>- 交互特性:等待时显示自己的画面,接通后还会显示通话计时。 |
|
|
809
|
+
|
|
810
|
+
### 设置通话的默认超时时间
|
|
811
|
+
|
|
812
|
+
您可以在发起通话 [calls](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callstore/calls(participantids:callmediatype:params:completion:)) 时,通过配置参数 [CallParams](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callparams) 中的 `timeout` 字段来指定等待超时时间。示例代码如下:
|
|
813
|
+
``` swift
|
|
814
|
+
var callParams = CallParams()
|
|
815
|
+
callParams.timeout = 30 // 设置通话超时为30秒
|
|
816
|
+
CallStore.shared.calls(
|
|
817
|
+
participantIds: userIdList,
|
|
818
|
+
mediaType: .video,
|
|
819
|
+
params: callParams,
|
|
820
|
+
completion: nil
|
|
821
|
+
)
|
|
822
|
+
```
|
|
823
|
+
| <strong>参数</strong> | <strong>类型</strong> | <strong>是否必填</strong> | <strong>说明</strong> |
|
|
824
|
+
| --- | --- | --- | --- |
|
|
825
|
+
| userIdList | List<String> | 是 | 目标用户的 userId 列表。 |
|
|
826
|
+
| mediaType | <a href="https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callmediatype">CallMediaType</a> | 是 | 通话媒体类型,用于指定发起音频通话还是视频通话。<br>- <code>CallMediaType.video</code> : 视频通话。<br>- <code>CallMediaType.audio</code> : 语音通话。 |
|
|
827
|
+
| params | <a href="https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/callparams">CallParams</a> | 否 | 通话扩展参数,如:房间号、通话邀请超时时间等。<br>- <code>roomId</code> (String) : 房间 ID,可选参数,未指定时由服务端自动分配。<br>- <code>timeout</code> (Int) : 呼叫超时时间(秒)。<br>- <code>userData</code> (String) : 用户自定义数据。<br>- <code>chatGroupId</code> (String) : Chat 群组 ID,用于群组通话场景。<br>- <code>isEphemeralCall</code> (Boolean) : 是否为加密通话(不产生通话记录)。 |
|
|
828
|
+
|
|
829
|
+
### 实现应用内悬浮窗
|
|
830
|
+
|
|
831
|
+
AtomicXCore SDK 提供了 `CallPipView` 组件,可以在应用内实现悬浮窗效果。当您的通话界面被其他页面覆盖时(例如用户点击了返回键但通话未结束),可以显示一个悬浮的小窗口,让用户随时查看通话状态并快速返回通话界面。
|
|
832
|
+
|
|
833
|
+
**第一步:**创建悬浮窗控制器。
|
|
834
|
+
``` swift
|
|
835
|
+
import UIKit
|
|
836
|
+
import AtomicXCore
|
|
837
|
+
import Combine
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* 悬浮窗控制器
|
|
841
|
+
*
|
|
842
|
+
* 用于显示通话悬浮窗,内部包含 CallCoreView
|
|
843
|
+
*/
|
|
844
|
+
class FloatWindowViewController: UIViewController {
|
|
845
|
+
|
|
846
|
+
var tapGestureAction: (() -> Void)?
|
|
847
|
+
private var cancellables = Set<AnyCancellable>()
|
|
848
|
+
|
|
849
|
+
private lazy var callCoreView: CallCoreView = {
|
|
850
|
+
let view = CallCoreView(frame: self.view.bounds)
|
|
851
|
+
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
852
|
+
view.setLayoutTemplate(.pip) // 设置为 Pip 布局模式
|
|
853
|
+
view.isUserInteractionEnabled = false // 禁用交互,让点击事件穿透到父视图
|
|
854
|
+
return view
|
|
855
|
+
}()
|
|
856
|
+
|
|
857
|
+
override func viewDidLoad() {
|
|
858
|
+
super.viewDidLoad()
|
|
859
|
+
view.backgroundColor = UIColor(white: 0.1, alpha: 1.0)
|
|
860
|
+
view.layer.cornerRadius = 10
|
|
861
|
+
view.layer.masksToBounds = true
|
|
862
|
+
|
|
863
|
+
view.addSubview(callCoreView)
|
|
864
|
+
|
|
865
|
+
// 添加点击手势
|
|
866
|
+
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap))
|
|
867
|
+
view.addGestureRecognizer(tapGesture)
|
|
868
|
+
|
|
869
|
+
// 延迟监听状态变化,避免在创建时立即被关闭
|
|
870
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { [weak self] in
|
|
871
|
+
self?.observeCallStatus()
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
@objc private func handleTap() {
|
|
876
|
+
tapGestureAction?()
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* 监听通话状态变化
|
|
881
|
+
* 当通话结束时自动关闭悬浮窗
|
|
882
|
+
*/
|
|
883
|
+
private func observeCallStatus() {
|
|
884
|
+
CallStore.shared.state
|
|
885
|
+
.subscribe(StatePublisherSelector<CallState, CallParticipantStatus>(keyPath: \.selfInfo.status))
|
|
886
|
+
.removeDuplicates()
|
|
887
|
+
.receive(on: DispatchQueue.main)
|
|
888
|
+
.sink { [weak self] status in
|
|
889
|
+
if status == .none {
|
|
890
|
+
// 通话结束,发送通知隐藏悬浮窗
|
|
891
|
+
NotificationCenter.default.post(name: NSNotification.Name("HideFloatingWindow"), object: nil)
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
.store(in: &cancellables)
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
deinit {
|
|
898
|
+
cancellables.removeAll()
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
```
|
|
902
|
+
|
|
903
|
+
**第二步:**在主界面实现悬浮窗管理逻辑。
|
|
904
|
+
``` swift
|
|
905
|
+
|
|
906
|
+
import UIKit
|
|
907
|
+
import AtomicXCore
|
|
908
|
+
|
|
909
|
+
class MainViewController: UIViewController {
|
|
910
|
+
|
|
911
|
+
private var floatWindow: UIWindow?
|
|
912
|
+
|
|
913
|
+
override func viewDidLoad() {
|
|
914
|
+
super.viewDidLoad()
|
|
915
|
+
|
|
916
|
+
// 监听显示悬浮窗的通知
|
|
917
|
+
NotificationCenter.default.addObserver(
|
|
918
|
+
self,
|
|
919
|
+
selector: #selector(showFloatingWindow),
|
|
920
|
+
name: NSNotification.Name("ShowFloatingWindow"),
|
|
921
|
+
object: nil
|
|
922
|
+
)
|
|
923
|
+
|
|
924
|
+
// 监听隐藏悬浮窗的通知
|
|
925
|
+
NotificationCenter.default.addObserver(
|
|
926
|
+
self,
|
|
927
|
+
selector: #selector(hideFloatingWindow),
|
|
928
|
+
name: NSNotification.Name("HideFloatingWindow"),
|
|
929
|
+
object: nil
|
|
930
|
+
)
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* 显示应用内悬浮窗
|
|
935
|
+
*/
|
|
936
|
+
@objc private func showFloatingWindow() {
|
|
937
|
+
// 检查通话是否进行中
|
|
938
|
+
let selfStatus = CallStore.shared.state.value.selfInfo.status
|
|
939
|
+
guard selfStatus == .accept else {
|
|
940
|
+
return
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
// 如果悬浮窗已存在,不重复创建
|
|
944
|
+
guard floatWindow == nil else { return }
|
|
945
|
+
|
|
946
|
+
// ⚠️ 关键:必须使用当前的 windowScene 来创建 window
|
|
947
|
+
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene else {
|
|
948
|
+
return
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
// 创建悬浮窗(宽高比 9:16)
|
|
952
|
+
let pipWidth: CGFloat = 100
|
|
953
|
+
let pipHeight: CGFloat = pipWidth * 16 / 9
|
|
954
|
+
let pipX = UIScreen.main.bounds.width - pipWidth - 20
|
|
955
|
+
let pipY: CGFloat = 100
|
|
956
|
+
|
|
957
|
+
// 创建悬浮窗 Window(关联到 windowScene)
|
|
958
|
+
let window = UIWindow(windowScene: windowScene)
|
|
959
|
+
window.windowLevel = .alert + 1
|
|
960
|
+
window.backgroundColor = .clear
|
|
961
|
+
window.frame = CGRect(x: pipX, y: pipY, width: pipWidth, height: pipHeight)
|
|
962
|
+
|
|
963
|
+
// 创建悬浮窗控制器
|
|
964
|
+
let floatVC = FloatWindowViewController()
|
|
965
|
+
floatVC.tapGestureAction = { [weak self] in
|
|
966
|
+
self?.openCallViewController()
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
window.rootViewController = floatVC
|
|
970
|
+
|
|
971
|
+
self.floatWindow = window
|
|
972
|
+
|
|
973
|
+
// 设置可见
|
|
974
|
+
window.isHidden = false
|
|
975
|
+
window.makeKeyAndVisible()
|
|
976
|
+
|
|
977
|
+
// 立即将主窗口恢复为 key window
|
|
978
|
+
if let mainWindow = windowScene.windows.first(where: { $0 != window }) {
|
|
979
|
+
mainWindow.makeKey()
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* 隐藏应用内悬浮窗
|
|
985
|
+
*/
|
|
986
|
+
@objc private func hideFloatingWindow() {
|
|
987
|
+
floatWindow?.isHidden = true
|
|
988
|
+
floatWindow = nil
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* 打开通话界面(从悬浮窗点击进入)
|
|
993
|
+
*/
|
|
994
|
+
private func openCallViewController() {
|
|
995
|
+
// 先隐藏悬浮窗
|
|
996
|
+
hideFloatingWindow()
|
|
997
|
+
|
|
998
|
+
// 获取当前最顶层的 ViewController
|
|
999
|
+
guard let topVC = getTopViewController() else {
|
|
1000
|
+
return
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
let callVC = CallViewController()
|
|
1004
|
+
callVC.modalPresentationStyle = .fullScreen
|
|
1005
|
+
topVC.present(callVC, animated: true)
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* 获取当前最顶层的 ViewController
|
|
1010
|
+
*/
|
|
1011
|
+
private func getTopViewController() -> UIViewController? {
|
|
1012
|
+
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
1013
|
+
let keyWindow = windowScene.windows.first(where: { $0.isKeyWindow }),
|
|
1014
|
+
let rootVC = keyWindow.rootViewController else {
|
|
1015
|
+
return nil
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
var topVC = rootVC
|
|
1019
|
+
while let presentedVC = topVC.presentedViewController {
|
|
1020
|
+
topVC = presentedVC
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
return topVC
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
deinit {
|
|
1027
|
+
NotificationCenter.default.removeObserver(self)
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
```
|
|
1031
|
+
|
|
1032
|
+
**第三步:**在通话界面添加悬浮窗触发逻辑。
|
|
1033
|
+
``` swift
|
|
1034
|
+
import UIKit
|
|
1035
|
+
import AtomicXCore
|
|
1036
|
+
|
|
1037
|
+
class CallViewController: UIViewController {
|
|
1038
|
+
|
|
1039
|
+
override func viewWillAppear(_ animated: Bool) {
|
|
1040
|
+
super.viewWillAppear(animated)
|
|
1041
|
+
|
|
1042
|
+
// 进入通话界面时,发送通知隐藏悬浮窗
|
|
1043
|
+
NotificationCenter.default.post(name: NSNotification.Name("HideFloatingWindow"), object: nil)
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
override func viewWillDisappear(_ animated: Bool) {
|
|
1047
|
+
super.viewWillDisappear(animated)
|
|
1048
|
+
|
|
1049
|
+
// 离开通话界面时,检查通话是否进行中
|
|
1050
|
+
let selfStatus = CallStore.shared.state.value.selfInfo.status
|
|
1051
|
+
if selfStatus == .accept {
|
|
1052
|
+
// 如果通话还在进行中,发送通知显示悬浮窗
|
|
1053
|
+
NotificationCenter.default.post(name: NSNotification.Name("ShowFloatingWindow"), object: nil)
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
```
|
|
1058
|
+
|
|
1059
|
+
### 实现应用外画中画
|
|
1060
|
+
|
|
1061
|
+
AtomicXCore SDK 支持通过底层 TRTC 引擎实现应用外画中画功能。当应用进入后台时,通话画面可以以系统画中画形式悬浮在其他应用之上,用户可以边使用其他应用边进行视频通话。实现方式如下:
|
|
1062
|
+
|
|
1063
|
+
> **说明:**
|
|
1064
|
+
>
|
|
1065
|
+
> 1. 需要在 Xcode 的 `Signing & Capabilities` 中添加 `Background Modes` 能力,并勾选 `Audio, AirPlay, and Picture in Picture。`
|
|
1066
|
+
> 2. 需要 iOS 15.0 及以上版本支持。
|
|
1067
|
+
|
|
1068
|
+
1. **配置画中画参数:**您需要设置画中画窗口的填充模式、用户视频区域、画布参数等参数。
|
|
1069
|
+
|
|
1070
|
+
``` swift
|
|
1071
|
+
import Foundation
|
|
1072
|
+
import AtomicXCore
|
|
1073
|
+
|
|
1074
|
+
// 填充模式枚举
|
|
1075
|
+
enum PictureInPictureFillMode: Int, Codable {
|
|
1076
|
+
case fill = 0 // 填充模式
|
|
1077
|
+
case fit = 1 // 适应模式
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
// 用户视频区域
|
|
1081
|
+
struct PictureInPictureRegion: Codable {
|
|
1082
|
+
let userId: String // 用户 ID
|
|
1083
|
+
let width: Double // 宽度(0.0-1.0,相对于画布)
|
|
1084
|
+
let height: Double // 高度(0.0-1.0,相对于画布)
|
|
1085
|
+
let x: Double // X 坐标(0.0-1.0,相对于画布左上角)
|
|
1086
|
+
let y: Double // Y 坐标(0.0-1.0,相对于画布左上角)
|
|
1087
|
+
let fillMode: PictureInPictureFillMode // 填充模式
|
|
1088
|
+
let streamType: String // 流类型("high" 或 "low")
|
|
1089
|
+
let backgroundColor: String // 背景颜色
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
// 画布配置
|
|
1093
|
+
struct PictureInPictureCanvas: Codable {
|
|
1094
|
+
let width: Int // 画布宽度
|
|
1095
|
+
let height: Int // 画布高度
|
|
1096
|
+
let backgroundColor: String // 背景颜色
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
// 画中画参数
|
|
1100
|
+
struct PictureInPictureParams: Codable {
|
|
1101
|
+
let enable: Bool // 是否启用画中画
|
|
1102
|
+
let cameraBackgroundCapture: Bool? // 是否在后台采集摄像头
|
|
1103
|
+
let canvas: PictureInPictureCanvas? // 画布配置(可选)
|
|
1104
|
+
let regions: [PictureInPictureRegion]? // 用户视频区域列表(可选)
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
// 画中画请求
|
|
1108
|
+
struct PictureInPictureRequest: Codable {
|
|
1109
|
+
let api: String // API 名称
|
|
1110
|
+
let params: PictureInPictureParams // 参数
|
|
1111
|
+
}
|
|
1112
|
+
```
|
|
1113
|
+
2. **启用画中画:**您可以通过`configPictureInPicture` 方法启用/关闭画中画功能。
|
|
1114
|
+
|
|
1115
|
+
``` swift
|
|
1116
|
+
let params = PictureInPictureParams(
|
|
1117
|
+
enable: true,
|
|
1118
|
+
cameraBackgroundCapture: true,
|
|
1119
|
+
canvas: nil,
|
|
1120
|
+
regions: nil
|
|
1121
|
+
)
|
|
1122
|
+
|
|
1123
|
+
let request = PictureInPictureRequest(
|
|
1124
|
+
api: "configPictureInPicture",
|
|
1125
|
+
params: params
|
|
1126
|
+
)
|
|
1127
|
+
|
|
1128
|
+
// 编码为 JSON 字符串
|
|
1129
|
+
let encoder = JSONEncoder()
|
|
1130
|
+
if let data = try? encoder.encode(request),
|
|
1131
|
+
let jsonString = String(data: data, encoding: .utf8) {
|
|
1132
|
+
TUICallEngine.createInstance().callExperimentalAPI(jsonObject: jsonString)
|
|
1133
|
+
}
|
|
1134
|
+
```
|
|
1135
|
+
|
|
1136
|
+
### 设置通话过程中屏幕常亮
|
|
1137
|
+
|
|
1138
|
+
通话过程中保持屏幕常亮是通话应用的基本需求。iOS 提供了 `UIApplication.shared.isIdleTimerDisabled` 属性来实现此功能。
|
|
1139
|
+
``` swift
|
|
1140
|
+
class CallViewController: UIViewController {
|
|
1141
|
+
|
|
1142
|
+
override func viewDidLoad() {
|
|
1143
|
+
super.viewDidLoad()
|
|
1144
|
+
|
|
1145
|
+
// 禁用自动锁屏,保持屏幕常亮
|
|
1146
|
+
UIApplication.shared.isIdleTimerDisabled = true
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
override func viewWillDisappear(_ animated: Bool) {
|
|
1150
|
+
super.viewWillDisappear(animated)
|
|
1151
|
+
|
|
1152
|
+
// 恢复自动锁屏
|
|
1153
|
+
UIApplication.shared.isIdleTimerDisabled = false
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
### 播放等待接听的提示音
|
|
1159
|
+
|
|
1160
|
+
您可以监听自己的通话状态,在等待接听时播放铃声,在接听通话或通话结束时停止播放铃声。
|
|
1161
|
+
``` swift
|
|
1162
|
+
import Combine
|
|
1163
|
+
|
|
1164
|
+
private var cancellables = Set<AnyCancellable>()
|
|
1165
|
+
|
|
1166
|
+
private func observeSelfCallStatus() {
|
|
1167
|
+
CallStore.shared.state.subscribe()
|
|
1168
|
+
.map { $0.selfInfo.status }
|
|
1169
|
+
.removeDuplicates()
|
|
1170
|
+
.receive(on: DispatchQueue.main)
|
|
1171
|
+
.sink { [weak self] status in
|
|
1172
|
+
if status == .accept || status == .none {
|
|
1173
|
+
// 停止播放铃声
|
|
1174
|
+
return
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
if status == .waiting {
|
|
1178
|
+
// 播放铃声
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
.store(in: &cancellables)
|
|
1182
|
+
}
|
|
1183
|
+
```
|
|
1184
|
+
|
|
1185
|
+
### 开启后台采集音频/视频
|
|
1186
|
+
|
|
1187
|
+
为了确保应用在进入后台时仍能正常采集音频和视频(例如用户锁屏或切换到其他应用),您需要配置 iOS 的后台模式权限并设置音频会话。
|
|
1188
|
+
|
|
1189
|
+
**配置步骤:**在 Xcode 中打开您的项目,按照以下步骤操作:
|
|
1190
|
+
1. 选择项目的 `Target` → `Signing & Capabilities`。
|
|
1191
|
+
|
|
1192
|
+
2. 点击 `+ Capability` 。
|
|
1193
|
+
|
|
1194
|
+
3. 搜索并添加 `Background Modes`。
|
|
1195
|
+
|
|
1196
|
+
4. 勾选以下三个选项:
|
|
1197
|
+
|
|
1198
|
+
- `Audio, AirPlay, and Picture in Picture`(保持音频采集和画中画功能)。
|
|
1199
|
+
|
|
1200
|
+
- `Voice over IP`(支持 VoIP 通话)。
|
|
1201
|
+
|
|
1202
|
+
- `Remote notifications`(可选,用于接收离线推送)。
|
|
1203
|
+
|
|
1204
|
+
配置完成后,您的 `Info.plist` 文件会自动添加以下内容:
|
|
1205
|
+
|
|
1206
|
+
``` xml
|
|
1207
|
+
<key>UIBackgroundModes</key>
|
|
1208
|
+
<array>
|
|
1209
|
+
<string>audio</string>
|
|
1210
|
+
<string>voip</string>
|
|
1211
|
+
<string>remote-notification</string>
|
|
1212
|
+
</array>
|
|
1213
|
+
```
|
|
1214
|
+
- **配置音频会话(AVAudioSession)**
|
|
1215
|
+
|
|
1216
|
+
为了确保通话音频在后台正常工作,您需要在通话开始前配置音频会话。建议在通话界面的 `viewDidLoad` 或发起通话前设置:
|
|
1217
|
+
|
|
1218
|
+
``` swift
|
|
1219
|
+
import AVFoundation
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* 设置音频会话,支持后台音频采集
|
|
1223
|
+
*
|
|
1224
|
+
* 建议在以下场景调用:
|
|
1225
|
+
* 1. 通话界面的 viewDidLoad 中
|
|
1226
|
+
* 2. 发起通话 (calls) 之前
|
|
1227
|
+
* 3. 接听通话 (accept) 之前
|
|
1228
|
+
*/
|
|
1229
|
+
private func setupAudioSession() {
|
|
1230
|
+
let audioSession = AVAudioSession.sharedInstance()
|
|
1231
|
+
do {
|
|
1232
|
+
// 设置音频会话类别为播放和录音
|
|
1233
|
+
// .allowBluetooth: 支持蓝牙耳机
|
|
1234
|
+
// .allowBluetoothA2DP: 支持高质量蓝牙音频(A2DP 协议)
|
|
1235
|
+
try audioSession.setCategory(.playAndRecord, options: [.allowBluetooth, .allowBluetoothA2DP])
|
|
1236
|
+
|
|
1237
|
+
// 激活音频会话
|
|
1238
|
+
try audioSession.setActive(true)
|
|
1239
|
+
} catch {
|
|
1240
|
+
// 音频会话配置失败
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
```
|
|
1244
|
+
- **播放铃声时的特殊处理(可选)**
|
|
1245
|
+
|
|
1246
|
+
如果您需要在等待接听时播放铃声,并且希望铃声通过扬声器播放,可以临时切换音频会话为 `.playback` 模式:
|
|
1247
|
+
|
|
1248
|
+
``` swift
|
|
1249
|
+
/**
|
|
1250
|
+
* 播放铃声时切换音频会话
|
|
1251
|
+
*
|
|
1252
|
+
* 使用场景:当您使用 AVAudioPlayer 播放铃声时
|
|
1253
|
+
*/
|
|
1254
|
+
private func setAudioSessionForRingtone() {
|
|
1255
|
+
let audioSession = AVAudioSession.sharedInstance()
|
|
1256
|
+
do {
|
|
1257
|
+
// 切换为播放模式
|
|
1258
|
+
try audioSession.setCategory(.playback, options: [.allowBluetooth, .allowBluetoothA2DP])
|
|
1259
|
+
// 强制使用扬声器播放铃声
|
|
1260
|
+
try audioSession.overrideOutputAudioPort(.speaker)
|
|
1261
|
+
try audioSession.setActive(true)
|
|
1262
|
+
} catch {
|
|
1263
|
+
// 铃声音频会话配置失败
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* 停止播放铃声后恢复为通话模式
|
|
1269
|
+
*/
|
|
1270
|
+
private func restoreAudioSessionForCall() {
|
|
1271
|
+
let audioSession = AVAudioSession.sharedInstance()
|
|
1272
|
+
do {
|
|
1273
|
+
// 恢复为播放和录音模式
|
|
1274
|
+
try audioSession.setCategory(.playAndRecord, options: [.allowBluetooth, .allowBluetoothA2DP])
|
|
1275
|
+
try audioSession.setActive(true)
|
|
1276
|
+
} catch {
|
|
1277
|
+
// 恢复音频会话失败
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
```
|
|
1281
|
+
|
|
1282
|
+
### 设置离线推送参数
|
|
1283
|
+
|
|
1284
|
+
## 下一步
|
|
1285
|
+
|
|
1286
|
+
恭喜您,已经完成了"拨打一通电话",接下来,您可参考 接听第一通电话 实现接听电话功能。
|
|
1287
|
+
|
|
1288
|
+
## 常见问题
|
|
1289
|
+
|
|
1290
|
+
### 在通话邀请超时时间内,被邀请者如果离线再上线,能否收到来电事件?
|
|
1291
|
+
|
|
1292
|
+
单人通话时,如果在超时时间内上线,会触发来电邀请;群组通话,如果在超时时间内上线,会拉起未处理的20条群消息,如果存在通话邀请,则触发来电邀请事件。
|