コンテンツにジャンプ

はじめに

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

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

    ターミナル画面
    bunx cap sync
  3. RINGソースを選択する SDK から受信コールイベントが来るか、Twilio または Stream などの 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: 最善の努力で回答しないタイムアウト
  • extra: リスナーパイロード内の任意のJSONがエコーされます
  • android.channelId そして android.channelName: Android通知チャンネル調整
  • android.showFullScreen: AndroidのフルスクリーンIncomingCallアクティビティを要求します
  • 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 オブジェクトが含まれます。

  • プラットフォームの注記を読んでください iOS ガイド __CAPGO_KEEP_0__
  • Read the Android ガイド __CAPGO_KEEP_0__
  • Web はサポートされていません。