@qusaieilouti99/call-manager 0.1.201 → 0.1.203

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.
@@ -13,21 +13,24 @@ Pod::Spec.new do |s|
13
13
  s.platforms = { :ios => min_ios_version_supported }
14
14
  s.source = { :git => "https://github.com/qusaieilouti99/call-manager.git", :tag => "#{s.version}" }
15
15
 
16
-
17
16
  s.source_files = [
18
17
  "ios/**/*.{swift}",
19
18
  "ios/**/*.{m,mm}",
20
19
  "cpp/**/*.{hpp,cpp}",
20
+ # Add the SharedDataManager from the host app
21
+ "../../ios/PingMe/SharedDataManager.swift"
21
22
  ]
22
23
 
23
- s.pod_target_xcconfig = {
24
- # C++ compiler flags, mainly for folly.
25
- "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES"
26
- }
24
+ s.pod_target_xcconfig = {
25
+ # C++ compiler flags, mainly for folly.
26
+ "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES"
27
+ }
27
28
 
28
29
  s.dependency 'React-jsi'
29
30
  s.dependency 'React-callinvoker'
30
31
  s.dependency 'JitsiWebRTC'
32
+ s.dependency 'MMKV'
33
+ s.dependency 'RealmSwift'
31
34
 
32
35
  load 'nitrogen/generated/ios/CallManager+autolinking.rb'
33
36
  add_nitrogen_files(s)
@@ -91,45 +91,81 @@ class VoIPTokenManager: NSObject, PKPushRegistryDelegate {
91
91
  // Initialize if not already initialized
92
92
  CallEngine.shared.initialize()
93
93
 
94
- // *** THIS IS THE WATCHDOG TIMER ***
95
- // It creates a failsafe that will call the completion handler after 10 seconds
96
- // if our main logic hangs or fails silently, preventing the OS from killing the app.
94
+ // *** WATCHDOG TIMER ***
97
95
  let completionTimeout = DispatchWorkItem {
98
96
  self.logger.error("⚠️ VoIP push handling timed out. Forcing completion.")
99
97
  completion()
100
98
  }
101
-
102
99
  DispatchQueue.main.asyncAfter(deadline: .now() + 10, execute: completionTimeout)
103
100
 
104
- // The payload is expected to have a specific structure.
105
- // Using a key like "custom_payload" or "data" is common.
106
- guard let info = payload.dictionaryPayload["custom_payload"] as? [AnyHashable: Any] else {
107
- logger.error("❌ Invalid payload format or missing 'custom_payload' dictionary.")
108
- completionTimeout.cancel() // Defuse the timer
101
+ // *** USE YOUR OLD FLEXIBLE PAYLOAD PARSING LOGIC ***
102
+ let full = payload.dictionaryPayload
103
+ logger.info("🔔 VoIP push full payload keys: \(full.keys)")
104
+
105
+ var userInfo: [AnyHashable: Any]?
106
+
107
+ // Check for aps["data"] as JSON string first
108
+ if let aps = full["aps"] as? [AnyHashable: Any],
109
+ let dataString = aps["data"] as? String,
110
+ let data = dataString.data(using: .utf8) {
111
+ logger.info("🔍 found aps[\"data\"] string (length=\(dataString.count))")
112
+ do {
113
+ let obj = try JSONSerialization.jsonObject(with: data, options: [])
114
+ if let nestedDict = obj as? [AnyHashable: Any] {
115
+ let keyList = nestedDict.keys.map { "\($0)" }
116
+ logger.info("🔍 parsed nested payload keys: \(keyList)")
117
+ userInfo = nestedDict
118
+ } else {
119
+ logger.error("❌ parsed aps[\"data\"] but it's not a dictionary")
120
+ }
121
+ } catch {
122
+ logger.error("❌ failed to JSON-parse aps[\"data\"]: \(error.localizedDescription)")
123
+ }
124
+ }
125
+
126
+ // Fallback to top-level "data" dictionary
127
+ if userInfo == nil, let topData = full["data"] as? [AnyHashable: Any] {
128
+ logger.info("🔍 found top-level \"data\" dictionary – keys: \(topData.keys)")
129
+ userInfo = topData
130
+ }
131
+
132
+ // Fallback to top-level "payload" dictionary
133
+ if userInfo == nil, let wrap = full["payload"] as? [AnyHashable: Any] {
134
+ logger.info("🔍 found top-level \"payload\" dictionary – keys: \(wrap.keys)")
135
+ userInfo = wrap
136
+ }
137
+
138
+ // NEW: Also check for your "custom_payload" structure
139
+ if userInfo == nil, let customPayload = full["custom_payload"] as? [AnyHashable: Any] {
140
+ logger.info("🔍 found top-level \"custom_payload\" dictionary – keys: \(customPayload.keys)")
141
+ userInfo = customPayload
142
+ }
143
+
144
+ guard let info = userInfo else {
145
+ logger.error("❌ Invalid payload format – no nested info found, full.keys: \(full.keys)")
146
+ completionTimeout.cancel()
109
147
  completion()
110
148
  return
111
149
  }
112
150
 
151
+ logger.info("✅ using custom payload keys: \(info.keys)")
152
+
113
153
  guard let callId = info["callId"] as? String,
114
- let callType = info["callType"] as? String,
115
- let displayName = info["name"] as? String
116
- else {
117
- logger
118
- .error(
119
- "❌ Missing required fields in VoIP payload: callId, callType, or name."
120
- )
121
- completionTimeout.cancel() // Defuse the timer
154
+ let callType = info["callType"] as? String,
155
+ let displayName = info["name"] as? String else {
156
+ logger.error("❌ Missing required fields in VoIP payload: callId, callType, or name. Available keys: \(info.keys)")
157
+ completionTimeout.cancel()
122
158
  completion()
123
159
  return
124
160
  }
125
161
 
126
- let pictureUrl = info["pictureUrl"] as? String
127
- let metadata = info["metadata"] as? String
162
+ // Use the more flexible field name checking from your old version
163
+ let pictureUrl = info["pictureUrl"] as? String ?? info["picture"] as? String
164
+ let metadata = info["metadata"] as? String ?? info["data"] as? String
128
165
 
129
166
  logger.info("📞 Reporting incoming call from VoIP push: \(callId)")
130
167
 
131
- // Delegate the call reporting to the CallEngine.
132
- // The CallEngine is self-initializing, making this call safe.
168
+ // Report to CallEngine
133
169
  CallEngine.shared.reportIncomingCall(
134
170
  callId: callId,
135
171
  callType: callType,
@@ -138,8 +174,7 @@ class VoIPTokenManager: NSObject, PKPushRegistryDelegate {
138
174
  metadata: metadata
139
175
  ) { success in
140
176
  self.logger.info("📞 CallKit report from VoIP push completed. Success: \(success)")
141
- // This is the crucial call to satisfy the PushKit watchdog.
142
- completionTimeout.cancel() // Defuse the timer
177
+ completionTimeout.cancel()
143
178
  completion()
144
179
  }
145
180
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qusaieilouti99/call-manager",
3
- "version": "0.1.201",
3
+ "version": "0.1.203",
4
4
  "description": "Call manager",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",