@capgo/capacitor-stream-call 7.0.5 → 7.1.0

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.
@@ -350,7 +350,7 @@ class StreamCallPlugin : Plugin() {
350
350
  changeActivityAsVisibleOnLockScreen(this@StreamCallPlugin.activity, false)
351
351
 
352
352
  // Notify that call has ended using our helper
353
- updateCallStatusAndNotify(call.id, "rejected")
353
+ updateCallStatusAndNotify(call.cid, "rejected")
354
354
 
355
355
  hideIncomingCall()
356
356
  } catch (e: Exception) {
@@ -1235,8 +1235,8 @@ class StreamCallPlugin : Plugin() {
1235
1235
  Log.d("StreamCallPlugin", "internalAcceptCall: setActiveCall completed for call ${call.id}")
1236
1236
 
1237
1237
  // Notify that call has started using helper
1238
- updateCallStatusAndNotify(call.id, "joined")
1239
- Log.d("StreamCallPlugin", "internalAcceptCall: updateCallStatusAndNotify(joined) called for ${call.id}")
1238
+ updateCallStatusAndNotify(call.cid, "joined")
1239
+ Log.d("StreamCallPlugin", "internalAcceptCall: updateCallStatusAndNotify(joined) called for ${call.cid}")
1240
1240
 
1241
1241
  // Show overlay view with the active call and make webview transparent
1242
1242
  runOnMainThread {
@@ -1983,7 +1983,7 @@ class StreamCallPlugin : Plugin() {
1983
1983
 
1984
1984
  @OptIn(InternalStreamVideoApi::class)
1985
1985
  private suspend fun endCallRaw(call: Call) {
1986
- val callId = call.id
1986
+ val callId = call.cid
1987
1987
  Log.d("StreamCallPlugin", "Attempting to end call $callId")
1988
1988
 
1989
1989
  try {
@@ -2107,7 +2107,7 @@ class StreamCallPlugin : Plugin() {
2107
2107
 
2108
2108
  @OptIn(DelicateCoroutinesApi::class)
2109
2109
  private fun transEndCallRaw(call: Call) {
2110
- val callId = call.id
2110
+ val callId = call.cid
2111
2111
  val savedCapacitorActivity = savedActivity
2112
2112
  if (savedCapacitorActivity == null) {
2113
2113
  Log.d("StreamCallPlugin", "Cannot perform transEndCallRaw for call $callId. savedCapacitorActivity is null")
@@ -49,6 +49,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
49
49
  private var activeCallSubscription: AnyCancellable?
50
50
  private var lastVoIPToken: String?
51
51
  private var touchInterceptView: TouchInterceptView?
52
+ private var needsTouchInterceptorSetup: Bool = false
52
53
 
53
54
  private var streamVideo: StreamVideo?
54
55
 
@@ -71,6 +72,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
71
72
 
72
73
  // Helper method to update call status and notify listeners
73
74
  private func updateCallStatusAndNotify(callId: String, state: String, userId: String? = nil, reason: String? = nil, caller: [String: Any]? = nil, members: [[String: Any]]? = nil) {
75
+ print("updateCallStatusAndNotify: callId: \(callId), state: \(state)")
74
76
  // Update stored call info
75
77
  currentCallId = callId
76
78
  currentCallState = state
@@ -241,6 +243,9 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
241
243
  print("- In call state detected")
242
244
  print("- All participants: \(String(describing: viewModel.participants))")
243
245
 
246
+ // Ensure views are set up first (important when accepting call from notification)
247
+ self.setupViews()
248
+
244
249
  // Create/update overlay and make visible when there's an active call
245
250
  self.createCallOverlayView()
246
251
 
@@ -290,8 +295,9 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
290
295
  print("Failed to get call info for caller details: \(error)")
291
296
  }
292
297
 
293
- // Notify with caller information
294
- self.updateCallStatusAndNotify(callId: incomingCall.id, state: "ringing", caller: caller, members: members)
298
+ // Notify with caller information
299
+ let fullCallId = "\(incomingCall.type):\(incomingCall.id)"
300
+ self.updateCallStatusAndNotify(callId: fullCallId, state: "ringing", caller: caller, members: members)
295
301
  }
296
302
  } else if newState == .idle {
297
303
  print("Call state changed to idle. CurrentCallId: \(self.currentCallId), ActiveCall: \(String(describing: self.streamVideo?.state.activeCall?.cId))")
@@ -592,7 +598,8 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
592
598
  }
593
599
 
594
600
  // Now send the created event with complete member data
595
- self.updateCallStatusAndNotify(callId: callId, state: "created", members: allMembers)
601
+ let fullCallId = "\(callType):\(callId)"
602
+ self.updateCallStatusAndNotify(callId: fullCallId, state: "created", members: allMembers)
596
603
 
597
604
  // Update UI on main thread
598
605
  await MainActor.run {
@@ -808,12 +815,19 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
808
815
 
809
816
  // Update the CallOverlayView with the active call
810
817
  await MainActor.run {
818
+ print("acceptCall: Setting up UI for accepted call")
819
+
820
+ // Ensure views are set up first
821
+ self.setupViews()
822
+
811
823
  // Add touch interceptor for the call
812
824
  self.addTouchInterceptor()
813
825
 
814
826
  // self.overlayViewModel?.updateCall(streamCall)
815
827
  self.overlayView?.isHidden = false
816
828
  self.webView?.isOpaque = false
829
+
830
+ print("acceptCall: UI setup complete - overlay visible: \(!self.overlayView!.isHidden), touch interceptor: \(self.touchInterceptView != nil)")
817
831
  }
818
832
 
819
833
  call.resolve([
@@ -926,10 +940,32 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
926
940
  ])
927
941
  }
928
942
  }
943
+
944
+ // Check if we have an active call and need to add touch interceptor
945
+ if let activeCall = self.streamVideo?.state.activeCall {
946
+ print("Active call detected during setupViews, ensuring touch interceptor is added")
947
+ // Make overlay visible if there's an active call
948
+ self.overlayView?.isHidden = false
949
+ self.webView?.isOpaque = false
950
+ // Add touch interceptor if not already present
951
+ self.addTouchInterceptor()
952
+ } else if self.needsTouchInterceptorSetup {
953
+ // If we previously tried to add touch interceptor but webview wasn't ready
954
+ print("Deferred touch interceptor setup detected, attempting to add now")
955
+ self.addTouchInterceptor()
956
+ // Reset the flag if successful
957
+ if self.touchInterceptView != nil {
958
+ self.needsTouchInterceptorSetup = false
959
+ }
960
+ }
929
961
  }
930
962
 
931
963
  private func addTouchInterceptor() {
932
- guard let webView = self.webView, let parent = webView.superview else { return }
964
+ guard let webView = self.webView, let parent = webView.superview else {
965
+ print("Cannot add touch interceptor - webView or parent not ready, marking for deferred setup")
966
+ self.needsTouchInterceptorSetup = true
967
+ return
968
+ }
933
969
 
934
970
  // Check if touch interceptor already exists
935
971
  if self.touchInterceptView != nil {
@@ -981,6 +1017,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
981
1017
  // Remove touch interceptor from view hierarchy
982
1018
  touchInterceptView.removeFromSuperview()
983
1019
  self.touchInterceptView = nil
1020
+ self.needsTouchInterceptorSetup = false
984
1021
 
985
1022
  print("Touch interceptor removed after call ended")
986
1023
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-stream-call",
3
- "version": "7.0.5",
3
+ "version": "7.1.0",
4
4
  "description": "Uses the https://getstream.io/ SDK to implement calling in Capacitor",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",