Erste Schritte
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-streamcall`
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/de/docs/plugins/streamcall/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.
Installation
Section titled “Installation”npm install @capgo/capacitor-stream-callnpx cap syncyarn add @capgo/capacitor-stream-callnpx cap syncpnpm add @capgo/capacitor-stream-callnpx cap syncbun add @capgo/capacitor-stream-callnpx cap syncVoraussetzungen
Section titled “Voraussetzungen”Sie benötigen ein Stream-Konto und API-Anmeldeinformationen. Registrieren Sie sich bei Stream, falls Sie noch kein Konto haben.
Plattform-Konfiguration
Section titled “Plattform-Konfiguration”Fügen Sie die erforderlichen Berechtigungen zu Ihrer Info.plist hinzu:
<key>NSCameraUsageDescription</key><string>Diese App benötigt Kamerazugriff für Videoanrufe</string><key>NSMicrophoneUsageDescription</key><string>Diese App benötigt Mikrofonzugriff für Videoanrufe</string>Android
Section titled “Android”Fügen Sie die erforderlichen Berechtigungen zu Ihrer AndroidManifest.xml hinzu:
<uses-permission android:name="android.permission.CAMERA" /><uses-permission android:name="android.permission.RECORD_AUDIO" /><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />Verwendungsbeispiel
Section titled “Verwendungsbeispiel”import { StreamCall } from '@capgo/capacitor-stream-call';
// Stream SDK initialisierenawait StreamCall.initialize({ apiKey: 'your-stream-api-key', userId: 'user-123', userToken: 'user-token'});
// Einen Anruf erstellenawait StreamCall.createCall({ callId: 'call-123', callType: 'default'});
// Einem Anruf beitretenawait StreamCall.joinCall({ callId: 'call-123'});
// Kamera aktivieren/deaktivierenawait StreamCall.toggleCamera({ enabled: true});
// Mikrofon aktivieren/deaktivierenawait StreamCall.toggleMicrophone({ enabled: true});
// Kamera wechseln (vorne/hinten)await StreamCall.switchCamera();
// Den Anruf verlassenawait StreamCall.leaveCall();
// Auf Anrufereignisse hörenStreamCall.addListener('callStarted', (data) => { console.log('Call started:', data);});
StreamCall.addListener('callEnded', (data) => { console.log('Call ended:', data);});
StreamCall.addListener('participantJoined', (data) => { console.log('Participant joined:', data);});
StreamCall.addListener('participantLeft', (data) => { console.log('Participant left:', data);});API-Referenz
Section titled “API-Referenz”initialize(options)
Section titled “initialize(options)”initialize(options: InitializeOptions) => Promise<void>Initialisiert das Stream Video SDK.
| Param | Type |
|---|---|
options | InitializeOptions |
createCall(options)
Section titled “createCall(options)”createCall(options: CreateCallOptions) => Promise<void>Erstellt einen neuen Videoanruf.
| Param | Type |
|---|---|
options | CreateCallOptions |
joinCall(options)
Section titled “joinCall(options)”joinCall(options: JoinCallOptions) => Promise<void>Tritt einem bestehenden Videoanruf bei.
| Param | Type |
|---|---|
options | JoinCallOptions |
leaveCall()
Section titled “leaveCall()”leaveCall() => Promise<void>Verlässt den aktuellen Anruf.
toggleCamera(options)
Section titled “toggleCamera(options)”toggleCamera(options: { enabled: boolean }) => Promise<void>Aktiviert oder deaktiviert die Kamera.
| Param | Type |
|---|---|
options | { enabled: boolean } |
toggleMicrophone(options)
Section titled “toggleMicrophone(options)”toggleMicrophone(options: { enabled: boolean }) => Promise<void>Aktiviert oder deaktiviert das Mikrofon.
| Param | Type |
|---|---|
options | { enabled: boolean } |
switchCamera()
Section titled “switchCamera()”switchCamera() => Promise<void>Wechselt zwischen Vorder- und Rückkamera.
setSpeakerphone(options)
Section titled “setSpeakerphone(options)”setSpeakerphone(options: { enabled: boolean }) => Promise<void>Aktiviert oder deaktiviert den Lautsprecher.
| Param | Type |
|---|---|
options | { enabled: boolean } |
sendCallInvite(options)
Section titled “sendCallInvite(options)”sendCallInvite(options: InviteOptions) => Promise<void>Sendet eine Anrufeinladung an einen Benutzer.
| Param | Type |
|---|---|
options | InviteOptions |
acceptCall(options)
Section titled “acceptCall(options)”acceptCall(options: { callId: string }) => Promise<void>Nimmt einen eingehenden Anruf an.
| Param | Type |
|---|---|
options | { callId: string } |
rejectCall(options)
Section titled “rejectCall(options)”rejectCall(options: { callId: string }) => Promise<void>Lehnt einen eingehenden Anruf ab.
| Param | Type |
|---|---|
options | { callId: string } |
Schnittstellen
Section titled “Schnittstellen”InitializeOptions
Section titled “InitializeOptions”| Prop | Type | Beschreibung |
|---|---|---|
apiKey | string | Stream API-Schlüssel |
userId | string | Benutzer-ID |
userToken | string | Benutzer-Authentifizierungstoken |
userName | string | Anzeigename des Benutzers (optional) |
userImage | string | Profilbild-URL des Benutzers (optional) |
CreateCallOptions
Section titled “CreateCallOptions”| Prop | Type | Beschreibung |
|---|---|---|
callId | string | Eindeutiger Anruf-Identifikator |
callType | string | Anruftyp (z.B. ‘default’, ‘audio-only’) |
members | string[] | Array von Benutzer-IDs zum Einladen (optional) |
JoinCallOptions
Section titled “JoinCallOptions”| Prop | Type | Beschreibung |
|---|---|---|
callId | string | Anruf-ID zum Beitreten |
InviteOptions
Section titled “InviteOptions”| Prop | Type | Beschreibung |
|---|---|---|
callId | string | Anruf-ID |
userId | string | Benutzer-ID zum Einladen |
Event-Listener
Section titled “Event-Listener”Verfügbare Ereignisse
Section titled “Verfügbare Ereignisse”callStarted- Anruf wurde gestartetcallEnded- Anruf wurde beendetparticipantJoined- Ein Teilnehmer ist dem Anruf beigetretenparticipantLeft- Ein Teilnehmer hat den Anruf verlassenincomingCall- Eingehender Anruf empfangencallAccepted- Anruf wurde angenommencallRejected- Anruf wurde abgelehnterror- Ein Fehler ist aufgetreten
Ereignis-Beispiel
Section titled “Ereignis-Beispiel”// Auf eingehende Anrufe hörenStreamCall.addListener('incomingCall', (data) => { console.log('Incoming call from:', data.callerId); console.log('Caller name:', data.callerName);
// Eingehenden Anruf-UI anzeigen showIncomingCallScreen({ callerId: data.callerId, callerName: data.callerName, callerImage: data.callerImage, callId: data.callId });});
// Auf Anrufannahme hörenStreamCall.addListener('callAccepted', (data) => { console.log('Call accepted'); // Zum Anruf-Bildschirm navigieren});
// Auf Fehler hörenStreamCall.addListener('error', (error) => { console.error('Call error:', error.message); // Fehler angemessen behandeln});
// Listener entfernen, wenn fertigconst listener = await StreamCall.addListener('callStarted', (data) => { console.log('Call started');});
// Später...listener.remove();Vollständiges Beispiel
Section titled “Vollständiges Beispiel”import { StreamCall } from '@capgo/capacitor-stream-call';
class VideoCallService { async initialize(userId: string, userName: string) { try { await StreamCall.initialize({ apiKey: 'your-stream-api-key', userId: userId, userToken: await this.getUserToken(userId), userName: userName });
this.setupEventListeners(); } catch (error) { console.error('Failed to initialize Stream:', error); } }
setupEventListeners() { // Eingehende Anrufe behandeln StreamCall.addListener('incomingCall', async (data) => { const accepted = await this.showIncomingCallDialog(data);
if (accepted) { await StreamCall.acceptCall({ callId: data.callId }); await StreamCall.joinCall({ callId: data.callId }); } else { await StreamCall.rejectCall({ callId: data.callId }); } });
// Anrufereignisse behandeln StreamCall.addListener('callStarted', () => { console.log('Call started'); });
StreamCall.addListener('callEnded', () => { console.log('Call ended'); this.navigateToHome(); });
StreamCall.addListener('participantJoined', (data) => { console.log('Participant joined:', data.participantName); }); }
async startCall(recipientId: string) { try { const callId = `call-${Date.now()}`;
// Anruf erstellen und beitreten await StreamCall.createCall({ callId: callId, callType: 'default', members: [recipientId] });
await StreamCall.joinCall({ callId: callId });
// Einladung senden await StreamCall.sendCallInvite({ callId: callId, userId: recipientId });
console.log('Call started'); } catch (error) { console.error('Failed to start call:', error); } }
async endCall() { try { await StreamCall.leaveCall(); console.log('Call ended'); } catch (error) { console.error('Failed to end call:', error); } }
async toggleVideo(enabled: boolean) { await StreamCall.toggleCamera({ enabled }); }
async toggleAudio(enabled: boolean) { await StreamCall.toggleMicrophone({ enabled }); }
async flipCamera() { await StreamCall.switchCamera(); }
private async getUserToken(userId: string): Promise<string> { // Benutzer-Token von Ihrem Backend abrufen const response = await fetch(`/api/stream-token?userId=${userId}`); const data = await response.json(); return data.token; }
private async showIncomingCallDialog(data: any): Promise<boolean> { // Nativen Dialog oder benutzerdefinierte UI anzeigen return confirm(`Incoming call from ${data.callerName}`); }
private navigateToHome() { // Zum Startbildschirm navigieren window.location.href = '/'; }}
// Verwendungconst videoCall = new VideoCallService();await videoCall.initialize('user-123', 'John Doe');
// Einen Anruf startenawait videoCall.startCall('user-456');
// Steuerelemente umschaltenawait videoCall.toggleVideo(false); // Video deaktivierenawait videoCall.toggleAudio(false); // Stummschaltenawait videoCall.flipCamera(); // Kamera wechseln
// Anruf beendenawait videoCall.endCall();Bewährte Methoden
Section titled “Bewährte Methoden”- Initialisieren Sie das SDK früh im Lebenszyklus Ihrer App
- Berechtigungsanfragen vor dem Start von Anrufen behandeln
- Implementieren Sie eine ordnungsgemäße Fehlerbehandlung für Netzwerkprobleme
- Listener aufräumen, wenn Komponenten demontiert werden
- Auf echten Geräten testen (nicht nur Emulatoren)
- Wiederverbindungslogik für Netzwerkunterbrechungen implementieren
- Visuelles Feedback für Anrufzustände bereitstellen
- Hintergrund-/Vordergrund-Übergänge behandeln
Lokalisierung
Section titled “Lokalisierung”Das Plugin unterstützt mehrere Sprachen für native UI-Elemente. Konfigurieren Sie dies in Ihren plattformspezifischen Einstellungen.
Anwendungsfälle
Section titled “Anwendungsfälle”- Einzelgespräche per Video
- Gruppen-Videokonferenzen
- Nur-Audio-Anrufe
- Bildschirmfreigabe-Sitzungen
- Kundensupport per Video-Chat
- Telemedizinische Konsultationen
- Remote-Zusammenarbeit