Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions app/lib/services/voip/useCallStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { create } from 'zustand';
import type { CallState, CallContact, IClientMediaCall } from '@rocket.chat/media-signaling';
import RNCallKeep from 'react-native-callkeep';
import InCallManager from 'react-native-incall-manager';

import Navigation from '../../navigation/appNavigation';

Expand Down Expand Up @@ -77,6 +78,12 @@ export const useCallStore = create<CallStore>((set, get) => ({
callStartTime: call.state === 'active' ? Date.now() : null
});

try {
InCallManager.start({ media: 'audio' });
} catch (error) {
console.error('[VoIP] InCallManager.start failed:', error);
}

// Subscribe to call events
const handleStateChange = () => {
const currentCall = get().call;
Expand Down Expand Up @@ -129,10 +136,18 @@ export const useCallStore = create<CallStore>((set, get) => ({
set({ isOnHold: !isOnHold });
},

toggleSpeaker: () => {
const { isSpeakerOn } = get();
// TODO: Implement actual speaker toggle via RNCallKeep or WebRTC audio routing
set({ isSpeakerOn: !isSpeakerOn });
toggleSpeaker: async () => {
const { callUUID, isSpeakerOn } = get();
if (!callUUID) return;

const newSpeakerOn = !isSpeakerOn;

try {
await InCallManager.setForceSpeakerphoneOn(newSpeakerOn);
set({ isSpeakerOn: newSpeakerOn });
} catch (error) {
console.error('[VoIP] Failed to toggle speaker:', error);
}
},

toggleFocus: () => {
Expand Down Expand Up @@ -165,6 +180,11 @@ export const useCallStore = create<CallStore>((set, get) => ({
},

reset: () => {
try {
InCallManager.stop();
} catch (error) {
console.error('[VoIP] InCallManager.stop failed:', error);
}
set(initialState);
}
}));
Expand Down
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,8 @@ PODS:
- React-logger (= 0.79.4)
- React-perflogger (= 0.79.4)
- React-utils (= 0.79.4)
- ReactNativeIncallManager (4.2.1):
- React-Core
- RNBootSplash (6.3.8):
- DoubleConversion
- glog
Expand Down Expand Up @@ -2743,6 +2745,7 @@ DEPENDENCIES:
- ReactAppDependencyProvider (from `build/generated/ios`)
- ReactCodegen (from `build/generated/ios`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- ReactNativeIncallManager (from `../node_modules/react-native-incall-manager`)
- RNBootSplash (from `../node_modules/react-native-bootsplash`)
- RNCallKeep (from `../node_modules/react-native-callkeep`)
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
Expand Down Expand Up @@ -3005,6 +3008,8 @@ EXTERNAL SOURCES:
:path: build/generated/ios
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
ReactNativeIncallManager:
:path: "../node_modules/react-native-incall-manager"
RNBootSplash:
:path: "../node_modules/react-native-bootsplash"
RNCallKeep:
Expand Down Expand Up @@ -3174,6 +3179,7 @@ SPEC CHECKSUMS:
ReactAppDependencyProvider: bf62814e0fde923f73fc64b7e82d76c63c284da9
ReactCodegen: 5c6b68a6cfdfce6b69a8b12d2eb93e1117d96113
ReactCommon: 177fca841e97b2c0e288e86097b8be04c6e7ae36
ReactNativeIncallManager: dccd3e7499caa3bb73d3acfedf4fb0360f1a87d5
RNBootSplash: 1280eeb18d887de0a45bb4923d4fc56f25c8b99c
RNCallKeep: 1930a01d8caf48f018be4f2db0c9f03405c2f977
RNCAsyncStorage: edb872909c88d8541c0bfade3f86cd7784a7c6b3
Expand Down
Loading
Loading