开始使用
复制一个包含安装步骤和此插件的完整 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.
-
安装包
终端窗口 bun add @capgo/capacitor-incoming-call-kit -
同步本地项目
终端窗口 bunx cap sync -
选择您的呼叫源 决定呼叫事件是否来自您的后端、SDK(如Twilio或Stream)还是原生推送路径(如FCM或PushKit)。
整合的组合方式
关于整合的组合方式此插件仅负责原生呼叫的呈现。您的应用程序仍负责传输、身份验证和实际媒体会话。
生产环境的常见模式是:
- 您的后端或呼叫SDK发送呼叫事件。
- 您的应用程序调用
showIncomingCall(). - 插件呈现原生呼叫界面。
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, 或者emailAddressfor 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 对象。
平台说明
标题为“平台说明”- 阅读 iOS 指南 在将 CallKit 集成到 PushKit 或 APNs 流程之前阅读。
- 阅读 Android 指南 在 Android 14 及更高版本中依赖全屏意图之前阅读。
- Web 不受支持。