Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleInviteReceivedEvent = event => {
const {
setIsReceivingCall,
call: { onCall },
addAdditionalCall
} = this.props;
logMessage(`handleInviteReceivedEvent with onCall: ${onCall}`);
logMessage(onCall);
if (onCall) {
addAdditionalCall();
}
// Retrieve the remote user information from the event data
const { uri } = event.data.session.remoteIdentity;
const phoneNumber = uri.user;
setIsReceivingCall(phoneNumber, null, this.getCurrentCallId());
RNCallKeep.displayIncomingCall(this.getCurrentCallId(), phoneNumber);
};
const displayIncomingCall = (number) => {
const callUUID = getNewUuid();
addCall(callUUID, number);
log(`[displayIncomingCall] ${format(callUUID)}, number: ${number}`);
RNCallKeep.displayIncomingCall(callUUID, number, number, 'number', false);
};
showIncomingCall(isVideoCall, displayName, callId) {
this.callKitUuid = uuid.v4();
this.withVideo = isVideoCall;
this.callId = callId;
RNCallKeep.displayIncomingCall(this.callKitUuid, displayName, displayName, 'generic', isVideoCall);
}
updateQuery: async (_, { subscriptionData }) => {
const { callID, type, fromUser, chat, message } = subscriptionData.data.webRTCMessage
const Busy = await RNCallKit.checkIfBusy()
if (Busy) {
await refuseCall(callID, chat._id, CALL_TYPES.BUSY)
}
if (type === 'offer') {
RNCallKit.displayIncomingCall(callID, fromUser, '', 'generic', true)
RNCallKit.addEventListener('endCall', () =>
refuseCall(callID, chat._id, CALL_TYPES.REJECT),
)
RNCallKit.addEventListener('answerCall', () =>
answerCall(callID, chat._id, fromUser, message),
)
}
},
})