Caller/Callee UX: - lib/ringback.ts + assets/sounds/ringback_eu.mp3 (EU 425Hz Festnetz-Tone) - stores/call.ts: stopRingback bei connected, hangup-reasons, logCallToChat fix - locales: 'Wird angerufen…' statt 'Ruft an…' CallKit (iOS) + ConnectionService (Android): - lib/callkit.ts: setupCallKeep, displayIncomingCall, startOutgoingCall, reportConnected/Ended (appName 'ReBreak-Audio', includesCallsInRecents=false für DSGVO/DiGA) - hooks/useCallKeepEvents.ts: native answer/end/mute → useCallStore-Actions - stores/call.ts: CallKit-Aufrufe an allen lifecycle-Punkten - app.config.ts: @config-plugins/react-native-callkeep + UIBackgroundModes voip/audio + Android-Telecom-Perms VoIP-PushKit Backend: - services/voip-push.ts: @parse/node-apn Provider mit .p12 (Topic org.rebreak.app.voip) - services/push.ts sendCallRingPush: feuert beide Pfade (VoIP iOS + Expo Android/Fallback) - prisma: push_tokens.voip_token Column + Migration 20260604 - api/users/me/push-token: optional voipToken im Body - Env (Infisical): APNS_VOIP_P12_PATH/PASSWORD/TOPIC/PRODUCTION Push-tap routing + cold-start handling: - app/_layout.tsx: type:'call' Push → useCallStore.receiveIncoming + /call Docs: ops/CALLKIT_SETUP.md (Apple-Portal-Steps für VoIP-Cert)
48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { useEffect } from 'react';
|
|
import { useRouter } from 'expo-router';
|
|
import { supabase } from '../lib/supabase';
|
|
import { useCallStore, type CallPeer } from '../stores/call';
|
|
|
|
/**
|
|
* Lauscht (app-weit, solange eingeloggt) auf den persönlichen Ring-Channel
|
|
* `call-ring:<myUserId>` und zeigt bei einer eingehenden Einladung den
|
|
* Call-Screen. Phase 1 = foreground-only (klingelt nur bei offener App;
|
|
* Wake-when-closed via VoIP-Push ist Phase 2).
|
|
*/
|
|
export function useIncomingCalls(myUserId: string | undefined) {
|
|
const router = useRouter();
|
|
|
|
useEffect(() => {
|
|
if (!myUserId) return;
|
|
|
|
console.log('[CALL/recv] subscribing call-ring channel for', myUserId);
|
|
const chan = supabase.channel(`call-ring:${myUserId}`);
|
|
chan.on('broadcast', { event: 'ring' }, (msg: any) => {
|
|
console.log('[CALL/recv] RING received', msg?.payload);
|
|
const callId = msg?.payload?.callId as string | undefined;
|
|
const from = msg?.payload?.from as CallPeer | undefined;
|
|
if (!callId || !from) return;
|
|
// Schon in einem Call → ignorieren (MVP: kein call-waiting).
|
|
if (useCallStore.getState().status !== 'idle') return;
|
|
useCallStore.getState().receiveIncoming(callId, from);
|
|
router.push('/call');
|
|
});
|
|
chan.on('broadcast', { event: 'cancel' }, (msg: any) => {
|
|
const callId = msg?.payload?.callId as string | undefined;
|
|
const st = useCallStore.getState();
|
|
if (st.callId === callId && st.status === 'incoming') {
|
|
// Caller hat aufgelegt bevor wir annehmen konnten → verpasster Anruf.
|
|
st.hangup('unanswered');
|
|
}
|
|
});
|
|
chan.subscribe((status: string, err?: any) => {
|
|
console.log('[CALL/recv] call-ring subscribe status:', status, err ?? '');
|
|
});
|
|
|
|
return () => {
|
|
console.log('[CALL/recv] unsubscribing call-ring for', myUserId);
|
|
supabase.removeChannel(chan);
|
|
};
|
|
}, [myUserId, router]);
|
|
}
|