Passer à la navigation

Prise en main

GitHub

Vous pouvez utiliser notre configuration assistée par l'IA pour installer le plugin. Ajoutez les Capgo compétences à votre outil AI en utilisant la commande suivante :

Fenêtre de terminal
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Ensuite, utilisez la prompt suivante :

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-incoming-call-kit` plugin in my project.

Si vous préférez la configuration manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à la plateforme ci-dessous :

  1. Installer le package

    Fenêtre de terminal
    bun add @capgo/capacitor-incoming-call-kit
  2. Synchroniser les projets natifs

    Fenêtre de terminal
    bunx cap sync
  3. Choisissez votre source de sonnerie 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.

Comment les éléments s'intègrent

Sous-titre « Comment les éléments s'intègrent »

Cette extension ne gère que la présentation d'appel entrant natif. Votre application conserve toujours la gestion du transport, de l'authentification et de la session média réelle.

Le modèle de production courant est :

  1. Your backend or calling SDK emits a ring event.
  2. Votre application appelle showIncomingCall().
  3. Le plugin présente une interface utilisateur d'appel entrant natif.
  4. callAccepted informe votre application pour rejoindre la salle ou la session VoIP réelle.
  5. callDeclined, callEnded, ou callTimedOut informe votre application pour nettoyer l'état distant.
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: identifiant stable réutilisé plus tard avec endCall()
  • timeoutMs: temps d'attente non répondu au mieux de ses capacités
  • extra: JSON arbitraire renvoyé dans les payloads des écouteurs
  • android.channelId et android.channelName: Réglage du canal de notification Android
  • android.showFullScreen: demande l'activité d'appel entrant à écran plein de l'Android
  • ios.handleType: choisir generic, phoneNumber, ou emailAddress pour CallKit
const { calls } = await IncomingCallKit.getActiveCalls();
await IncomingCallKit.endCall({
callId: 'call-42',
reason: 'remote-ended',
});
await IncomingCallKit.endAllCalls({
reason: 'session-reset',
});
  • incomingCallDisplayed: l'IHM native a été affichée avec succès
  • callAccepted: l'utilisateur a accepté depuis l'interface native
  • callDeclined: l'utilisateur a refusé avant de rejoindre
  • callEnded: votre application ou la plateforme a terminé l'appel suivi
  • callTimedOut: l'appel est resté sans réponse jusqu'à timeoutMs

Chaque événement transporte le payload normalisé et votre objet original. call Notes de la plateforme extra Section intitulée « Notes de la plateforme »

Continuez de la section « Commencer »

Section intitulée « Commencer »

Si vous utilisez Commencer pour planifier le tableau de bord et les opérations API, connectez-l’avec En utilisant @capgo/capacitor-kit-appel-entrant pour la capacité native en utilisant En utilisant @capgo/capacitor-kit-appel-entrant, Vue d'ensemble de API pour les détails d'implémentation dans API Vue d'ensemble Introduction pour les détails d'implémentation dans Introduction API Clés pour les détails d'implémentation dans API Clés, et Appareils pour les détails d'implémentation dans Appareils.