I am trying to receive an incoming call from a user who is calling me but I am not getting any call from that user on the user side it's giving an error message that Cal Failed Reason: Not Found I am using Voximplant react native i have both the users in my voximplant control panel but still this problem is coming
I set up my code that way first it hit an API and if it gives the message "Ok" then it will only login and user and listing for incoming calls what is the problem with my code?
import { Voximplant } from 'react-native-voximplant';
import calls from './store';
import { VOXIMPLANT_APP, VOXIMPLANT_ACCOUNT } from '../Constants/voximplant';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { Platform } from 'react-native';
export const initVoximplant = (navigation) => {
const login = async () => {
try {
const voximplant = Voximplant.getInstance();
const userDataString = await AsyncStorage.getItem('user');
const e = await JSON.parse(userDataString!);
const clientState = await voximplant.getClientState();
if (clientState === Voximplant.ClientState.DISCONNECTED) {
await voximplant.connect();
await voximplant.login(
`${e.user._id}@${VOXIMPLANT_APP}.${VOXIMPLANT_ACCOUNT}.voximplant.com`,
e.user._id,
);
}
if (clientState === Voximplant.ClientState.CONNECTED) {
await voximplant.login(
`${e.user._id}@${VOXIMPLANT_APP}.${VOXIMPLANT_ACCOUNT}.voximplant.com`,
e.user._id,
);
}
} catch (e) {
console.log("Error is je", e)
let message = 'Unknown error. Try again';
if (e.name === Voximplant.ClientEvents.ConnectionFailed) {
message = 'Connection error, check your internet connection';
}
}
};
const a = Platform.OS === 'ios' ? 'http://localhost:3000' : 'http://10.0.2.2:3000';
const checkUserNotifee = async () => {
try {
const userDataString = await AsyncStorage.getItem('user');
const e = await JSON.parse(userDataString!);
const voximplant = Voximplant.getInstance();
const response = await fetch(`${a}/notifeeuser`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
user: e.user._id
}),
});
const data = await response.json();
if (data.message === 'Ok') {
login()
voximplant.on(Voximplant.ClientEvents.IncomingCall, (incomingCallEvent) => {
calls.set(incomingCallEvent.call.callId, incomingCallEvent.call);
console.log(incomingCallEvent.call.callId, incomingCallEvent.call)
navigation.navigate('IncomingCall', {
callId: incomingCallEvent.call.callId,
});
});
return function cleanup() {
voximplant.off(Voximplant.ClientEvents.IncomingCall);
};
}
} catch (error) {
console.log(error);
}
};
checkUserNotifee();
};