Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
startOutgoingCallViaCallKit(isVideo, number) {
this.callKitManager.startOutgoingCall(isVideo, number, this.call.callId);
this.call.on(Voximplant.CallEvents.Connected, this._callConnected);
this.call.on(Voximplant.CallEvents.Disconnected, this._callDisconnected);
}
_incomingCall = (event) => {
if (this.call !== null) {
console.log(`CallManager: incomingCall: already have a call, rejecting new call, current call id: ${this.call.callId}`);
event.call.decline();
return;
}
this.addCall(event.call);
this.call.on(Voximplant.CallEvents.Disconnected, this._callDisconnected);
if (Platform.OS === 'ios') {
if (this.currentAppState === 'active') {
console.log('CallManager: _incomingCall: report incoming call to CallKit');
this.callKitManager.showIncomingCall(event.video, event.call.getEndpoints()[0].displayName, event.call.callId);
} else {
console.log('CallManager: _incomingCall: application is in the background, incoming call is already reported in AppDelegate');
this.callKitManager.callId = event.call.callId;
this.callKitManager.withVideo = event.video;
}
} else {
this._showIncomingScreenOrNotification(event);
}
};
setupListeners() {
if (this.call) {
Object.keys(Voximplant.CallEvents).forEach((eventName) => {
const callbackName = `_onCall${eventName}`;
if (typeof this[callbackName] !== 'undefined') {
this.call.on(eventName, this[callbackName]);
}
});
if (this.isIncoming) {
this.call.getEndpoints().forEach(endpoint => {
this._setupEndpointListeners(endpoint, true);
});
}
}
}
componentWillUnmount() {
if (this.call) {
Object.keys(Voximplant.CallEvents).forEach((eventName) => {
const callbackName = `_onCall${eventName}`;
if (typeof this[callbackName] !== 'undefined') {
this.call.off(eventName, this[callbackName]);
}
});
this.call = null;
}
}