コンテンツにスキップ

はじめに

  1. パッケージをインストール

    ターミナル画面
    bun add @capgo/capacitor-incoming-call-kit
  2. ネイティブプロジェクトを同期

    ターミナル画面
    bunx cap sync
  3. RING ソースを選択 SDK から受信コールイベントが来るか、バックエンド、Twilio などの SDK、または FCM または PushKit のようなネイティブ プッシュ パスを決定する

このプラグインは、ネイティブの受信コール表示のみを所有します。アプリは、トランスポート、認証、および実際のメディア セッションを所有します。

一般的なプロダクション パターンは

  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: Androidで未回答のタイムアウトをベストエフォートで要求
  • extra: リスナー パayloadに反映されるアーキテクチャ
  • android.channelId そして android.channelName: AndroidのフルスクリーンIncomingCallアクティビティを要求
  • android.showFullScreen: Androidの通知チャンネル設定
  • ios.handleType: 選択 generic, phoneNumber, または emailAddress for 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: __CAPGO_KEEP_0__ が返信されなかった timeoutMs

各イベントには、正常化された call ペイロードと元の extra オブジェクトが含まれます。

プラットフォームに関する注意

「プラットフォームに関する注意」