@qusaieilouti99/call-manager 0.1.154 → 0.1.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/CallEngine.swift +2 -3
- package/ios/VoIPTokenManager.swift +31 -22
- package/package.json +1 -1
package/ios/CallEngine.swift
CHANGED
|
@@ -62,7 +62,7 @@ class CallEngine {
|
|
|
62
62
|
|
|
63
63
|
// MARK: Incoming
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
func reportIncomingCall(callId: String,
|
|
66
66
|
callType: String,
|
|
67
67
|
displayName: String,
|
|
68
68
|
pictureUrl: String? = nil,
|
|
@@ -75,8 +75,7 @@ class CallEngine {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// collision
|
|
78
|
-
if let inc = activeCalls.values.first(where: { $0.state == .incoming })
|
|
79
|
-
inc.callId != callId
|
|
78
|
+
if let inc = activeCalls.values.first(where: { $0.state == .incoming })
|
|
80
79
|
{
|
|
81
80
|
logger.warning("incoming collision → reject \(callId)")
|
|
82
81
|
emitEvent(.callRejected, data: ["callId": callId, "reason": "Another incoming exists"])
|
|
@@ -60,9 +60,9 @@ class VoIPTokenManager: NSObject, PKPushRegistryDelegate {
|
|
|
60
60
|
|
|
61
61
|
// MARK: - PKPushRegistryDelegate
|
|
62
62
|
func pushRegistry(_ registry: PKPushRegistry,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
didReceiveIncomingPushWith payload: PKPushPayload,
|
|
64
|
+
for type: PKPushType,
|
|
65
|
+
completion: @escaping () -> Void)
|
|
66
66
|
{
|
|
67
67
|
// 1) Log the full incoming payload
|
|
68
68
|
let full = payload.dictionaryPayload
|
|
@@ -111,7 +111,7 @@ class VoIPTokenManager: NSObject, PKPushRegistryDelegate {
|
|
|
111
111
|
// 3) Bail if we still have no custom info
|
|
112
112
|
guard let info = userInfo else {
|
|
113
113
|
logger.error("❌ invalid payload – no nested info found, full.keys: \(full.keys)")
|
|
114
|
-
completion()
|
|
114
|
+
completion() // Call completion immediately if parsing fails
|
|
115
115
|
return
|
|
116
116
|
}
|
|
117
117
|
logger.info("✅ using custom payload keys: \(info.keys)")
|
|
@@ -123,7 +123,7 @@ class VoIPTokenManager: NSObject, PKPushRegistryDelegate {
|
|
|
123
123
|
let displayName = info["name"] as? String
|
|
124
124
|
else {
|
|
125
125
|
logger.error("❌ missing one of: callId / callType / name in keys: \(info.keys)")
|
|
126
|
-
completion()
|
|
126
|
+
completion() // Call completion immediately if essential info is missing
|
|
127
127
|
return
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -133,23 +133,32 @@ class VoIPTokenManager: NSObject, PKPushRegistryDelegate {
|
|
|
133
133
|
let metadata = info["metadata"] as? String
|
|
134
134
|
?? info["data"] as? String
|
|
135
135
|
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
CallEngine.shared.endCall(callId: callId)
|
|
140
|
-
} else {
|
|
141
|
-
logger.info("📞 VoIP push → IncomingCall \(callId), displayName=\(displayName)")
|
|
142
|
-
CallEngine.shared.reportIncomingCall(
|
|
143
|
-
callId: callId,
|
|
144
|
-
callType: callType,
|
|
145
|
-
displayName: displayName,
|
|
146
|
-
pictureUrl: pictureUrl,
|
|
147
|
-
metadata: metadata
|
|
148
|
-
)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// 7) Call completion
|
|
136
|
+
// *** CRITICAL CHANGE: Call completion() here ***
|
|
137
|
+
// This tells iOS that you have received and processed the push notification,
|
|
138
|
+
// and it can release the resources allocated for handling it.
|
|
152
139
|
completion()
|
|
153
|
-
logger.info("🔔 didReceiveIncomingPush completed")
|
|
140
|
+
logger.info("🔔 didReceiveIncomingPush completed (signaled to system, starting background work)")
|
|
141
|
+
|
|
142
|
+
// 6) Dispatch to your CallEngine on a background queue.
|
|
143
|
+
// This ensures that any potentially time-consuming operations within CallEngine
|
|
144
|
+
// do not block the main thread or delay the completion handler.
|
|
145
|
+
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
|
|
146
|
+
guard let self = self else { return } // Avoid capturing self strongly in closure
|
|
147
|
+
|
|
148
|
+
if let nt = info["type"] as? String, nt == "EndCall" {
|
|
149
|
+
self.logger.info("📞 VoIP push → EndCall \(callId)")
|
|
150
|
+
CallEngine.shared.endCall(callId: callId)
|
|
151
|
+
} else {
|
|
152
|
+
self.logger.info("📞 VoIP push → IncomingCall \(callId), displayName=\(displayName)")
|
|
153
|
+
CallEngine.shared.reportIncomingCall(
|
|
154
|
+
callId: callId,
|
|
155
|
+
callType: callType,
|
|
156
|
+
displayName: displayName,
|
|
157
|
+
pictureUrl: pictureUrl,
|
|
158
|
+
metadata: metadata
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
self.logger.info("🔔 CallEngine work finished for VoIP push")
|
|
162
|
+
}
|
|
154
163
|
}
|
|
155
164
|
}
|