@@ -56,23 +56,34 @@ extension VoIPController: PKPushRegistryDelegate {
5656
5757 if type == . voIP{
5858 let callId = callData [ " session_id " ] as! String
59- let callType = callData [ " call_type " ] as! Int
60- let callInitiatorId = callData [ " caller_id " ] as! Int
61- let callInitiatorName = callData [ " caller_name " ] as! String
62- let callOpponentsString = callData [ " call_opponents " ] as! String
63- let callOpponents = callOpponentsString. components ( separatedBy: " , " )
64- . map { Int ( $0) ?? 0 }
65- let userInfo = callData [ " user_info " ] as? String
59+ let signalingType = callData [ " signal_type " ] as? String
6660
67- self . callKitController. reportIncomingCall ( uuid: callId. lowercased ( ) , callType: callType, callInitiatorId: callInitiatorId, callInitiatorName: callInitiatorName, opponents: callOpponents, userInfo: userInfo) { ( error) in
61+ if ( signalingType != nil && ( signalingType == " endCall " || signalingType == " rejectCall " ) ) {
62+ self . callKitController. reportCallEnded ( uuid: UUID ( uuidString: callId. lowercased ( ) ) !, reason: CallEndedReason . remoteEnded)
6863
6964 completion ( )
65+ } else if ( signalingType != nil && signalingType == " startCall " ) {
66+ let callType = callData [ " call_type " ] as! Int
67+ let callInitiatorId = callData [ " caller_id " ] as! Int
68+ let callInitiatorName = callData [ " caller_name " ] as! String
69+ let callOpponentsString = callData [ " call_opponents " ] as! String
70+ let callOpponents = callOpponentsString. components ( separatedBy: " , " )
71+ . map { Int ( $0) ?? 0 }
72+ let userInfo = callData [ " user_info " ] as? String
7073
71- if ( error == nil ) {
72- print ( " [VoIPController][didReceiveIncomingPushWith] reportIncomingCall SUCCESS " )
73- } else {
74- print ( " [VoIPController][didReceiveIncomingPushWith] reportIncomingCall ERROR: \( error? . localizedDescription ?? " none " ) " )
74+ self . callKitController. reportIncomingCall ( uuid: callId. lowercased ( ) , callType: callType, callInitiatorId: callInitiatorId, callInitiatorName: callInitiatorName, opponents: callOpponents, userInfo: userInfo) { ( error) in
75+
76+ completion ( )
77+
78+ if ( error == nil ) {
79+ print ( " [VoIPController][didReceiveIncomingPushWith] reportIncomingCall SUCCESS " )
80+ } else {
81+ print ( " [VoIPController][didReceiveIncomingPushWith] reportIncomingCall ERROR: \( error? . localizedDescription ?? " none " ) " )
82+ }
7583 }
84+ } else {
85+ print ( " [VoIPController][didReceiveIncomingPushWith] unknown 'signal_type' was received " )
86+ completion ( )
7687 }
7788 } else {
7889 completion ( )
0 commit comments