@stream-io/react-native-callingx 0.1.0-beta.3 → 0.1.0-beta.5

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.
@@ -21,9 +21,8 @@ NS_ASSUME_NONNULL_BEGIN
21
21
  * supportsDTMF:NO
22
22
  * supportsGrouping:NO
23
23
  * supportsUngrouping:NO
24
- * fromPushKit:YES
25
24
  * payload:payload
26
- * withCompletionHandler:^{ }];
25
+ * withCompletionHandler:^(void){ }];
27
26
  * ```
28
27
  */
29
28
  @interface Callingx : NSObject
@@ -41,9 +40,8 @@ NS_ASSUME_NONNULL_BEGIN
41
40
  * @param supportsDTMF Whether the call supports DTMF tones
42
41
  * @param supportsGrouping Whether the call can be grouped with other calls
43
42
  * @param supportsUngrouping Whether the call can be ungrouped
44
- * @param fromPushKit Whether this call is from a PushKit notification
45
43
  * @param payload Optional payload data from the push notification
46
- * @param completion Completion handler called after the call is reported
44
+ * @param completion Completion handler called after the call is reported, with an error if the call could not be displayed
47
45
  */
48
46
  + (void)reportNewIncomingCall:(NSString *)callId
49
47
  handle:(NSString *)handle
@@ -54,7 +52,6 @@ NS_ASSUME_NONNULL_BEGIN
54
52
  supportsDTMF:(BOOL)supportsDTMF
55
53
  supportsGrouping:(BOOL)supportsGrouping
56
54
  supportsUngrouping:(BOOL)supportsUngrouping
57
- fromPushKit:(BOOL)fromPushKit
58
55
  payload:(NSDictionary * _Nullable)payload
59
56
  withCompletionHandler:(void (^_Nullable)(void))completion;
60
57
 
@@ -1,34 +1,78 @@
1
1
  import Foundation
2
2
 
3
3
  @objcMembers public class UUIDStorage: NSObject {
4
- private var uuidDict: [String: String] = [:]
5
- private var cidDict: [String: String] = [:]
4
+ /// Primary storage: cid -> CallingxCall
5
+ private var callsByCid: [String: CallingxCall] = [:]
6
+ /// Reverse lookup: lowercased UUID string -> CallingxCall
7
+ private var callsByUUID: [String: CallingxCall] = [:]
6
8
  private let queue = DispatchQueue(label: "com.stream.uuidstorage", attributes: [])
7
9
 
8
10
  public override init() {
9
11
  super.init()
10
12
  }
11
13
 
14
+ // MARK: - CallingxCall-based API (new)
15
+
16
+ /// Returns the existing call for the given cid, or creates a new one.
17
+ public func getOrCreateCall(forCid cid: String, isOutgoing: Bool = false) -> CallingxCall {
18
+ return queue.sync {
19
+ if let existing = callsByCid[cid] {
20
+ #if DEBUG
21
+ print("[UUIDStorage] getOrCreateCall: found existing \(existing)")
22
+ #endif
23
+ return existing
24
+ }
25
+
26
+ let uuid = UUID()
27
+ let call = CallingxCall(uuid: uuid, cid: cid, isOutgoing: isOutgoing)
28
+ let uuidString = uuid.uuidString.lowercased()
29
+ callsByCid[cid] = call
30
+ callsByUUID[uuidString] = call
31
+ #if DEBUG
32
+ print("[UUIDStorage] getOrCreateCall: created \(call)")
33
+ #endif
34
+ return call
35
+ }
36
+ }
37
+
38
+ /// Returns the call for the given cid, or nil if not found.
39
+ public func getCall(forCid cid: String) -> CallingxCall? {
40
+ return queue.sync {
41
+ return callsByCid[cid]
42
+ }
43
+ }
44
+
45
+ /// Returns the call for the given UUID, or nil if not found.
46
+ public func getCallByUUID(_ uuid: UUID) -> CallingxCall? {
47
+ return queue.sync {
48
+ let uuidString = uuid.uuidString.lowercased()
49
+ return callsByUUID[uuidString]
50
+ }
51
+ }
52
+
53
+ // MARK: - Legacy API (preserved for backward compatibility)
54
+
12
55
  public func allUUIDs() -> [UUID] {
13
56
  return queue.sync {
14
- return uuidDict.values.compactMap { UUID(uuidString: $0.lowercased()) }
57
+ return callsByCid.values.map { $0.uuid }
15
58
  }
16
59
  }
17
60
 
61
+ /// Returns the existing UUID for the given cid, or creates a new CallingxCall and returns its UUID.
18
62
  public func getOrCreateUUID(forCid cid: String) -> UUID {
19
63
  return queue.sync {
20
- // Check if cid exists (inlined to avoid nested sync call)
21
- if let existingUUID = uuidDict[cid] {
64
+ if let existing = callsByCid[cid] {
22
65
  #if DEBUG
23
- print("[UUIDStorage] getUUIDForCid: found existing UUID \(existingUUID) for cid \(cid)")
66
+ print("[UUIDStorage] getUUIDForCid: found existing UUID \(existing.uuid.uuidString.lowercased()) for cid \(cid)")
24
67
  #endif
25
- return UUID(uuidString: existingUUID) ?? UUID()
68
+ return existing.uuid
26
69
  }
27
70
 
28
71
  let uuid = UUID()
72
+ let call = CallingxCall(uuid: uuid, cid: cid, isOutgoing: false)
29
73
  let uuidString = uuid.uuidString.lowercased()
30
- uuidDict[cid] = uuidString
31
- cidDict[uuidString] = cid
74
+ callsByCid[cid] = call
75
+ callsByUUID[uuidString] = call
32
76
  #if DEBUG
33
77
  print("[UUIDStorage] getUUIDForCid: created new UUID \(uuidString) for cid \(cid)")
34
78
  #endif
@@ -38,15 +82,14 @@ import Foundation
38
82
 
39
83
  public func getUUID(forCid cid: String) -> UUID? {
40
84
  return queue.sync {
41
- guard let uuidString = uuidDict[cid] else { return nil }
42
- return UUID(uuidString: uuidString)
85
+ return callsByCid[cid]?.uuid
43
86
  }
44
87
  }
45
88
 
46
89
  public func getCid(forUUID uuid: UUID) -> String? {
47
90
  return queue.sync {
48
91
  let uuidString = uuid.uuidString.lowercased()
49
- let cid = cidDict[uuidString]
92
+ let cid = callsByUUID[uuidString]?.cid
50
93
  #if DEBUG
51
94
  print("[UUIDStorage] getCidForUUID: UUID \(uuidString) -> cid \(cid ?? "(not found)")")
52
95
  #endif
@@ -57,11 +100,11 @@ import Foundation
57
100
  public func removeCid(forUUID uuid: UUID) {
58
101
  queue.sync {
59
102
  let uuidString = uuid.uuidString.lowercased()
60
- if let cid = cidDict[uuidString] {
61
- uuidDict.removeValue(forKey: cid)
62
- cidDict.removeValue(forKey: uuidString)
103
+ if let call = callsByUUID[uuidString] {
104
+ callsByCid.removeValue(forKey: call.cid)
105
+ callsByUUID.removeValue(forKey: uuidString)
63
106
  #if DEBUG
64
- print("[UUIDStorage] removeCidForUUID: removed cid \(cid) for UUID \(uuidString)")
107
+ print("[UUIDStorage] removeCidForUUID: removed cid \(call.cid) for UUID \(uuidString)")
65
108
  #endif
66
109
  } else {
67
110
  #if DEBUG
@@ -73,9 +116,10 @@ import Foundation
73
116
 
74
117
  public func removeCid(_ cid: String) {
75
118
  queue.sync {
76
- if let uuidString = uuidDict[cid] {
77
- cidDict.removeValue(forKey: uuidString)
78
- uuidDict.removeValue(forKey: cid)
119
+ if let call = callsByCid[cid] {
120
+ let uuidString = call.uuid.uuidString.lowercased()
121
+ callsByUUID.removeValue(forKey: uuidString)
122
+ callsByCid.removeValue(forKey: cid)
79
123
  #if DEBUG
80
124
  print("[UUIDStorage] removeCid: removed cid \(cid) with UUID \(uuidString)")
81
125
  #endif
@@ -89,9 +133,9 @@ import Foundation
89
133
 
90
134
  public func removeAllObjects() {
91
135
  queue.sync {
92
- let count = uuidDict.count
93
- uuidDict.removeAll()
94
- cidDict.removeAll()
136
+ let count = callsByCid.count
137
+ callsByCid.removeAll()
138
+ callsByUUID.removeAll()
95
139
  #if DEBUG
96
140
  print("[UUIDStorage] removeAllObjects: cleared \(count) entries")
97
141
  #endif
@@ -100,25 +144,26 @@ import Foundation
100
144
 
101
145
  public func count() -> Int {
102
146
  return queue.sync {
103
- return uuidDict.count
147
+ return callsByCid.count
104
148
  }
105
149
  }
106
150
 
107
151
  public func containsCid(_ cid: String) -> Bool {
108
152
  return queue.sync {
109
- return uuidDict[cid] != nil
153
+ return callsByCid[cid] != nil
110
154
  }
111
155
  }
112
156
 
113
157
  public func containsUUID(_ uuid: UUID) -> Bool {
114
158
  return queue.sync {
115
- return cidDict[uuid.uuidString.lowercased()] != nil
159
+ return callsByUUID[uuid.uuidString.lowercased()] != nil
116
160
  }
117
161
  }
118
162
 
119
163
  public override var description: String {
120
164
  return queue.sync {
121
- return "UUIDStorage: \(uuidDict)"
165
+ let entries = callsByCid.map { "\($0.key): \($0.value)" }.joined(separator: ", ")
166
+ return "UUIDStorage: [\(entries)]"
122
167
  }
123
168
  }
124
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/react-native-callingx",
3
- "version": "0.1.0-beta.3",
3
+ "version": "0.1.0-beta.5",
4
4
  "description": "CallKit and Telecom API capabilities for React Native",
5
5
  "main": "./dist/module/index.js",
6
6
  "module": "./dist/module/index.js",
@@ -61,7 +61,7 @@
61
61
  "devDependencies": {
62
62
  "@react-native-community/cli": "20.0.1",
63
63
  "@react-native/babel-preset": "^0.81.5",
64
- "@stream-io/react-native-webrtc": "137.1.2-alpha.1",
64
+ "@stream-io/react-native-webrtc": "137.1.2",
65
65
  "@types/react": "^19.1.0",
66
66
  "del-cli": "^6.0.0",
67
67
  "react": "19.1.0",
@@ -70,7 +70,7 @@
70
70
  "typescript": "^5.9.2"
71
71
  },
72
72
  "peerDependencies": {
73
- "@stream-io/react-native-webrtc": ">=137.1.1",
73
+ "@stream-io/react-native-webrtc": ">=137.1.2",
74
74
  "react": "*",
75
75
  "react-native": "*"
76
76
  },
@@ -196,8 +196,8 @@ class CallingxModule implements ICallingxModule {
196
196
  return NativeCallingModule.endCallWithReason(callId, reasons[reason]);
197
197
  }
198
198
 
199
- isCallRegistered(callId: string): boolean {
200
- return NativeCallingModule.isCallRegistered(callId);
199
+ isCallTracked(callId: string): boolean {
200
+ return NativeCallingModule.isCallTracked(callId);
201
201
  }
202
202
 
203
203
  hasRegisteredCall(): boolean {
@@ -109,7 +109,7 @@ export interface Spec extends TurboModule {
109
109
  },
110
110
  ): Promise<void>;
111
111
 
112
- isCallRegistered(callId: string): boolean;
112
+ isCallTracked(callId: string): boolean;
113
113
 
114
114
  hasRegisteredCall(): boolean;
115
115
 
package/src/types.ts CHANGED
@@ -76,11 +76,11 @@ export interface ICallingxModule {
76
76
  ): Promise<void>;
77
77
 
78
78
  /**
79
- * Check if the call is registered in CallKit/Telecom.
79
+ * Check if the call is tracked in the native calling module.
80
80
  * @param callId - The call id.
81
81
  * @returns The boolean value.
82
82
  */
83
- isCallRegistered(callId: string): boolean;
83
+ isCallTracked(callId: string): boolean;
84
84
 
85
85
  /**
86
86
  * Check if there is a registered call.