跳过内容

开始

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.

如果您更喜欢手动设置,请运行以下命令并遵循以下平台特定的说明:

  1. 安装包

    终端窗口
    bun add @capgo/capacitor-incoming-call-kit
  2. 同步本机项目

    终端窗口
    bunx cap sync
  3. 选择呼叫铃声来源 决定呼叫事件是否来自您的后端、一个像 SDK 的服务(例如 Twilio 或 Stream)还是一个本机推送路径(例如 FCM 或 PushKit)。

如何集成工作

标题:如何集成工作

本插件仅负责本机呼叫的呈现。您的应用程序仍然负责传输、身份验证和实际媒体会话。

生产模式通常是这样的:

  1. 您的后端或呼叫 SDK 发出呼叫铃声事件。
  2. 您的应用程序调用 showIncomingCall().
  3. 该插件呈现原生 incoming-call 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: listener 有效载荷中随机 JSON 回显
  • android.channelIdandroid.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 : 对象。

  • : 读取 context HTML text fragment from a longer Capgo UI string (parent key `read_the_style_guide`). Page/area: Capgo marketing website. Role: Website copy sentence. Seen in: page contributing.astro. Message key `read_the_style_guide` (Read The Style Guide).
  • 开始阅读 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__ 说明 Capgo API 和 for the implementation detail in API Keys, and 编辑页面 上一个