跳过内容

开始使用

GitHub

安装

安装

您可以使用我们的 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.

如果您prefer手动设置,请按照以下命令安装插件并遵循以下平台特定说明:

  1. 安装包

    终端窗口
    bun add @capgo/capacitor-incoming-call-kit
  2. 上下文:Capgo营销网站。角色:UI标签。见于:页面代理/[slug].astro。消息键`agents_page_copy_label` (代理页面复制标签)。

    终端窗口
    bunx cap sync
  3. 同步本地项目 Decide whether the incoming-call event comes from your backend, an SDK such as Twilio or Stream, or a native push path such as FCM or PushKit.

如何整合工作

如何集成

标题:如何集成

这个插件只负责本地incoming-call的呈现。你的应用仍然负责传输、认证和实际媒体会话。

  1. 您的后端或呼叫SDK发出一个铃声事件。
  2. 您的应用程序调用 showIncomingCall().
  3. 插件呈现本机呼入呼叫UI。
  4. callAccepted 告诉您的应用程序加入实际房间或VoIP会话。
  5. 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: 监听器载荷中的任意 JSON 回显
  • android.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 对象。

平台注意事项

标题:平台注意事项

继续从 Getting Started 如果您正在使用 计划仪表板和API操作,连接它 使用@capgo/capacitor-incoming-call-kit 为使用@capgo/capacitor-incoming-call-kit的原生能力 API概述 为API概述的实现细节 介绍 为介绍的实现细节 API密钥 为API密钥的实现细节,以及 设备 为设备的实现细节。