开始
复制一个包含安装步骤和本插件完整Markdown指南的设置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-incoming-call-kit`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/incoming-call-kit/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
安装
标题为“安装”您可以使用我们的 AI 助手设置来安装插件。使用以下命令将 Capgo 技能添加到您的 AI 工具中:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下提示:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-incoming-call-kit` plugin in my project.如果您更喜欢手动设置,请运行以下命令并按照以下平台特定的说明进行安装:
-
安装包
终端窗口 bun add @capgo/capacitor-incoming-call-kit -
同步本地项目
终端窗口 bunx cap sync -
选择呼叫铃声来源 决定呼叫事件是否来自您的后端、一个像Twilio或Stream这样的SDK,还是一个本地推送路径,如FCM或PushKit。
如何集成工作
标题:如何集成工作本插件仅负责本地呼叫呈现。您的应用程序仍然负责传输、身份验证和实际媒体会话。
生产模式通常是这样的:
- 您的后端或呼叫SDK发出铃声事件。
- 您的应用程序调用
showIncomingCall(). - 该插件呈现本地呼入呼叫 UI。
callAccepted告诉您的应用程序加入实际房间或 VoIP 会话。callDeclined,callEnded, 或callTimedOut告诉您的应用程序清除远程状态。
最小集成
标题为“最小集成”import { IncomingCallKit } from '@capgo/capacitor-incoming-call-kit';
await IncomingCallKit.requestPermissions();await IncomingCallKit.requestFullScreenIntentPermission();
await IncomingCallKit.addListener('callAccepted', async ({ call }) => { console.log('Accepted', call.callId, call.extra); // Start or join your real call session here.});
await IncomingCallKit.addListener('callDeclined', ({ call }) => { console.log('Declined', call.callId); // Tell your backend or SDK that the user declined.});
await IncomingCallKit.addListener('callTimedOut', ({ call }) => { console.log('Timed out', call.callId); // Clear ringing state in your backend or SDK.});
await IncomingCallKit.showIncomingCall({ callId: 'call-42', callerName: 'Ada Lovelace', handle: '+39 555 010 020', appName: 'Capgo Phone', hasVideo: true, timeoutMs: 45_000, extra: { roomId: 'room-42', callerUserId: 'user_ada', }, android: { channelId: 'calls', channelName: 'Incoming Calls', showFullScreen: true, }, ios: { handleType: 'phoneNumber', },});重要选项
标题为“重要选项”callId: 稳定标识符后续重用endCall()timeoutMs: 最佳努力未回答超时extra: 在监听器负载中回显任意 JSONandroid.channelId和android.channelName: Android 通知频道调节android.showFullScreen: 请求 Android 全屏 incoming-call 活动ios.handleType: 选择generic,phoneNumber, 或emailAddress用于 CallKit
管理活跃呼叫
标题:管理活跃呼叫const { calls } = await IncomingCallKit.getActiveCalls();
await IncomingCallKit.endCall({ callId: 'call-42', reason: 'remote-ended',});
await IncomingCallKit.endAllCalls({ reason: 'session-reset',});事件模型
标题:事件模型incomingCallDisplayed: 本地 UI 已成功显示callAccepted: 用户接受了来自原生 UI 的呼叫callDeclined: 用户在加入前拒绝了呼叫callEnded: 你的应用或平台结束了跟踪的呼叫callTimedOut: 呼叫一直未被回应直到timeoutMs
每个事件都携带了标准化的 call 数据载荷和你的原始 extra 对象。
平台注意事项
标题为“平台注意事项”- 阅读 上下文:HTML 文本片段来自更长的 Capgo UI 字符串(父级键 `read_the_style_guide`)。 页面/区域:Capgo 市场网站。 角色:网站副本句子。 见于:astro.contributing.astro 页面。 消息键 `read_the_style_guide`(Read The Style Guide)。 iOS 指南前置条件:在将 CallKit 与 PushKit 或 APNs 流程集成之前
- 阅读 Android 指南 在 Android 14 和更高版本中,请在全屏意图上不应依赖
- Web 不受支持
继续从 Getting Started
继续从 Getting Started如果您正在使用 Getting Started 来规划仪表板和API操作,连接它到 使用 @capgo/capacitor-incoming-call-kit 使用 @capgo/capacitor-incoming-call-kit API概述 Capgo API 简介 简介 Capgo __CAPGO_KEEP_0__ keys Capgo API keys 和 for the implementation detail in API Keys, and 编辑页面 上一个