@@ -56,23 +56,34 @@ extension VoIPController: PKPushRegistryDelegate {
56
56
57
57
if type == . voIP{
58
58
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
66
60
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)
68
63
69
64
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
70
73
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
+ }
75
83
}
84
+ } else {
85
+ print ( " [VoIPController][didReceiveIncomingPushWith] unknown 'signal_type' was received " )
86
+ completion ( )
76
87
}
77
88
} else {
78
89
completion ( )
0 commit comments