@capgo/capacitor-stream-call 0.0.25-alpha.0 → 0.0.26
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/android/src/main/java/ee/forgr/capacitor/streamcall/CustomNotificationHandler.kt +93 -16
- package/ios/Sources/StreamCallPlugin/CallOverlayView.swift +1 -1
- package/ios/Sources/StreamCallPlugin/CustomVideoParticipantsView.swift +1 -1
- package/ios/Sources/StreamCallPlugin/ParticipantsView.swift +2 -2
- package/ios/Sources/StreamCallPlugin/StreamCallPlugin.swift +46 -56
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
package ee.forgr.capacitor.streamcall
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import android.app.Application
|
|
4
4
|
import android.app.Notification
|
|
5
5
|
import android.app.NotificationManager
|
|
@@ -8,13 +8,17 @@ import android.content.Context
|
|
|
8
8
|
import android.content.Intent
|
|
9
9
|
import android.media.RingtoneManager
|
|
10
10
|
import android.os.Build
|
|
11
|
+
import android.util.Log
|
|
11
12
|
import androidx.core.app.NotificationCompat
|
|
13
|
+
import io.getstream.log.taggedLogger
|
|
14
|
+
import io.getstream.video.android.core.RingingState
|
|
12
15
|
import io.getstream.video.android.core.notifications.DefaultNotificationHandler
|
|
16
|
+
import io.getstream.video.android.core.notifications.NotificationHandler
|
|
13
17
|
import io.getstream.video.android.model.StreamCallId
|
|
14
|
-
|
|
18
|
+
|
|
15
19
|
// declare "incoming_calls_custom" as a constant
|
|
16
20
|
const val INCOMING_CALLS_CUSTOM = "incoming_calls_custom"
|
|
17
|
-
|
|
21
|
+
|
|
18
22
|
class CustomNotificationHandler(
|
|
19
23
|
val application: Application,
|
|
20
24
|
private val endCall: (callId: StreamCallId) -> Unit = {},
|
|
@@ -25,17 +29,89 @@ class CustomNotificationHandler(
|
|
|
25
29
|
private const val KEY_NOTIFICATION_TIME = "notification_creation_time"
|
|
26
30
|
}
|
|
27
31
|
private var allowSound = true;
|
|
28
|
-
|
|
29
|
-
override fun
|
|
32
|
+
|
|
33
|
+
override fun getRingingCallNotification(
|
|
34
|
+
ringingState: RingingState,
|
|
35
|
+
callId: StreamCallId,
|
|
36
|
+
callDisplayName: String?,
|
|
37
|
+
shouldHaveContentIntent: Boolean,
|
|
38
|
+
): Notification? {
|
|
39
|
+
return if (ringingState is RingingState.Incoming) {
|
|
40
|
+
val fullScreenPendingIntent = intentResolver.searchIncomingCallPendingIntent(callId)
|
|
41
|
+
val acceptCallPendingIntent = intentResolver.searchAcceptCallPendingIntent(callId)
|
|
42
|
+
val rejectCallPendingIntent = intentResolver.searchRejectCallPendingIntent(callId)
|
|
43
|
+
|
|
44
|
+
if (fullScreenPendingIntent != null && acceptCallPendingIntent != null && rejectCallPendingIntent != null) {
|
|
45
|
+
customGetIncomingCallNotification(
|
|
46
|
+
fullScreenPendingIntent,
|
|
47
|
+
acceptCallPendingIntent,
|
|
48
|
+
rejectCallPendingIntent,
|
|
49
|
+
callDisplayName,
|
|
50
|
+
shouldHaveContentIntent,
|
|
51
|
+
callId
|
|
52
|
+
)
|
|
53
|
+
} else {
|
|
54
|
+
Log.e("CustomNotificationHandler", "Ringing call notification not shown, one of the intents is null.")
|
|
55
|
+
null
|
|
56
|
+
}
|
|
57
|
+
} else if (ringingState is RingingState.Outgoing) {
|
|
58
|
+
val outgoingCallPendingIntent = intentResolver.searchOutgoingCallPendingIntent(callId)
|
|
59
|
+
val endCallPendingIntent = intentResolver.searchEndCallPendingIntent(callId)
|
|
60
|
+
|
|
61
|
+
if (outgoingCallPendingIntent != null && endCallPendingIntent != null) {
|
|
62
|
+
getOngoingCallNotification(
|
|
63
|
+
callId,
|
|
64
|
+
callDisplayName,
|
|
65
|
+
isOutgoingCall = true,
|
|
66
|
+
)
|
|
67
|
+
} else {
|
|
68
|
+
Log.e("CustomNotificationHandler", "Ringing call notification not shown, one of the intents is null.")
|
|
69
|
+
null
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
null
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
fun customGetIncomingCallNotification(
|
|
30
77
|
fullScreenPendingIntent: PendingIntent,
|
|
31
78
|
acceptCallPendingIntent: PendingIntent,
|
|
32
79
|
rejectCallPendingIntent: PendingIntent,
|
|
33
80
|
callerName: String?,
|
|
34
81
|
shouldHaveContentIntent: Boolean,
|
|
82
|
+
callId: StreamCallId
|
|
35
83
|
): Notification {
|
|
36
|
-
|
|
37
|
-
customCreateIncomingCallChannel()
|
|
38
|
-
|
|
84
|
+
|
|
85
|
+
// customCreateIncomingCallChannel()
|
|
86
|
+
val manufacturer = Build.MANUFACTURER.lowercase()
|
|
87
|
+
if (manufacturer.contains("xiaomi") || manufacturer.contains("mi")) {
|
|
88
|
+
// val serviceIntent = Intent(application, CallForegroundService::class.java)
|
|
89
|
+
// serviceIntent.action = CallForegroundService.ACTION_START_FOREGROUND_SERVICE
|
|
90
|
+
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
91
|
+
// application.startForegroundService(serviceIntent)
|
|
92
|
+
// } else {
|
|
93
|
+
// application.startService(serviceIntent)
|
|
94
|
+
// }
|
|
95
|
+
// Adjust PendingIntent for Xiaomi to avoid permission denial
|
|
96
|
+
val xiaomiAcceptIntent = PendingIntent.getActivity(
|
|
97
|
+
application,
|
|
98
|
+
0,
|
|
99
|
+
Intent("io.getstream.video.android.action.ACCEPT_CALL")
|
|
100
|
+
.setPackage(application.packageName)
|
|
101
|
+
.putExtra(NotificationHandler.INTENT_EXTRA_CALL_CID, callId),
|
|
102
|
+
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
|
103
|
+
)
|
|
104
|
+
return buildNotification(
|
|
105
|
+
fullScreenPendingIntent,
|
|
106
|
+
xiaomiAcceptIntent,
|
|
107
|
+
rejectCallPendingIntent,
|
|
108
|
+
callerName,
|
|
109
|
+
shouldHaveContentIntent,
|
|
110
|
+
INCOMING_CALLS_CUSTOM,
|
|
111
|
+
true // Include sound
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
39
115
|
return buildNotification(
|
|
40
116
|
fullScreenPendingIntent,
|
|
41
117
|
acceptCallPendingIntent,
|
|
@@ -46,7 +122,7 @@ class CustomNotificationHandler(
|
|
|
46
122
|
true // Include sound
|
|
47
123
|
)
|
|
48
124
|
}
|
|
49
|
-
|
|
125
|
+
|
|
50
126
|
fun buildNotification(
|
|
51
127
|
fullScreenPendingIntent: PendingIntent,
|
|
52
128
|
acceptCallPendingIntent: PendingIntent,
|
|
@@ -64,10 +140,10 @@ class CustomNotificationHandler(
|
|
|
64
140
|
setOngoing(true)
|
|
65
141
|
setAutoCancel(false)
|
|
66
142
|
setCategory(NotificationCompat.CATEGORY_CALL)
|
|
67
|
-
|
|
143
|
+
|
|
68
144
|
// Clear all defaults first
|
|
69
145
|
setDefaults(0)
|
|
70
|
-
|
|
146
|
+
|
|
71
147
|
if (includeSound && allowSound) {
|
|
72
148
|
setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE))
|
|
73
149
|
setDefaults(NotificationCompat.DEFAULT_VIBRATE or NotificationCompat.DEFAULT_LIGHTS)
|
|
@@ -75,7 +151,7 @@ class CustomNotificationHandler(
|
|
|
75
151
|
setSound(null)
|
|
76
152
|
setDefaults(NotificationCompat.DEFAULT_VIBRATE or NotificationCompat.DEFAULT_LIGHTS)
|
|
77
153
|
}
|
|
78
|
-
|
|
154
|
+
|
|
79
155
|
// setVibrate(longArrayOf(0, 1000, 500, 1000))
|
|
80
156
|
setLights(0xFF0000FF.toInt(), 1000, 1000)
|
|
81
157
|
setFullScreenIntent(fullScreenPendingIntent, true)
|
|
@@ -95,12 +171,12 @@ class CustomNotificationHandler(
|
|
|
95
171
|
// flags = flags or NotificationCompat.FLAG_ONGOING_EVENT
|
|
96
172
|
}
|
|
97
173
|
}
|
|
98
|
-
|
|
174
|
+
|
|
99
175
|
override fun onMissedCall(callId: StreamCallId, callDisplayName: String) {
|
|
100
176
|
endCall(callId)
|
|
101
177
|
super.onMissedCall(callId, callDisplayName)
|
|
102
178
|
}
|
|
103
|
-
|
|
179
|
+
|
|
104
180
|
private fun customCreateIncomingCallChannel() {
|
|
105
181
|
maybeCreateChannel(
|
|
106
182
|
channelId = INCOMING_CALLS_CUSTOM,
|
|
@@ -114,7 +190,7 @@ class CustomNotificationHandler(
|
|
|
114
190
|
importance = NotificationManager.IMPORTANCE_HIGH
|
|
115
191
|
this.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
|
|
116
192
|
this.setShowBadge(true)
|
|
117
|
-
|
|
193
|
+
|
|
118
194
|
// Set the channel to be silent since we handle sound via RingtonePlayer
|
|
119
195
|
setSound(null, null)
|
|
120
196
|
enableVibration(true)
|
|
@@ -126,8 +202,9 @@ class CustomNotificationHandler(
|
|
|
126
202
|
},
|
|
127
203
|
)
|
|
128
204
|
}
|
|
129
|
-
|
|
205
|
+
|
|
130
206
|
public fun clone(): CustomNotificationHandler {
|
|
131
207
|
return CustomNotificationHandler(this.application, this.endCall, this.incomingCall)
|
|
132
208
|
}
|
|
133
209
|
}
|
|
210
|
+
|
|
@@ -57,7 +57,7 @@ struct CallOverlayView: View {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
private func changeTrackVisibility(_ participant: CallParticipant?, isVisible: Bool) {
|
|
60
|
-
|
|
60
|
+
print("changeTrackVisibility for \(String(describing: participant?.userId)), visible: \(isVisible)")
|
|
61
61
|
guard let participant = participant,
|
|
62
62
|
let call = viewModel.call else { return }
|
|
63
63
|
Task {
|
|
@@ -29,7 +29,7 @@ public struct CustomVideoCallParticipantView<Factory: ViewFactory>: View {
|
|
|
29
29
|
customData: [String: RawJSON],
|
|
30
30
|
call: Call?
|
|
31
31
|
) {
|
|
32
|
-
|
|
32
|
+
print("size: \(availableFrame.size)")
|
|
33
33
|
self.viewFactory = viewFactory
|
|
34
34
|
self.participant = participant
|
|
35
35
|
self.id = id ?? participant.id
|
|
@@ -34,8 +34,8 @@ extension View {
|
|
|
34
34
|
value: [ViewFramePreferenceData(label: label,
|
|
35
35
|
frame: geo.frame(in: .global))])
|
|
36
36
|
.onAppear {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
print("ParticipantsView - Collecting frame for label: \(label)")
|
|
38
|
+
print("Frame: \(geo.frame(in: .global))")
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
)
|
|
@@ -5,7 +5,6 @@ import StreamVideoSwiftUI
|
|
|
5
5
|
import SwiftUI
|
|
6
6
|
import Combine
|
|
7
7
|
import WebKit
|
|
8
|
-
import os.log
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Please read the Capacitor iOS Plugin Development Guide
|
|
@@ -28,15 +27,6 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
28
27
|
CAPPluginMethod(name: "getCallStatus", returnType: CAPPluginReturnPromise)
|
|
29
28
|
]
|
|
30
29
|
|
|
31
|
-
// OSLog for streamcall plugin
|
|
32
|
-
private static let osLog = OSLog(subsystem: "com.example.plugin.streamcall", category: "StreamCallPlugin")
|
|
33
|
-
|
|
34
|
-
// Static function for dual printing to console and os.log
|
|
35
|
-
public static func dualprint(_ message: String) {
|
|
36
|
-
print(message)
|
|
37
|
-
os_log("%{public}@", log: osLog, type: .info, message)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
30
|
private enum State {
|
|
41
31
|
case notInitialized
|
|
42
32
|
case initializing
|
|
@@ -107,7 +97,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
107
97
|
|
|
108
98
|
// Check if we have a logged in user for handling incoming calls
|
|
109
99
|
if let credentials = SecureUserRepository.shared.loadCurrentUser() {
|
|
110
|
-
|
|
100
|
+
print("Loading user for StreamCallPlugin: \(credentials.user.name)")
|
|
111
101
|
DispatchQueue.global(qos: .userInitiated).async {
|
|
112
102
|
self.initializeStreamVideo()
|
|
113
103
|
}
|
|
@@ -118,7 +108,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
118
108
|
wrappedDelegate: self.webView?.navigationDelegate,
|
|
119
109
|
onSetupOverlay: { [weak self] in
|
|
120
110
|
guard let self = self else { return }
|
|
121
|
-
|
|
111
|
+
print("Attempting to setup call view")
|
|
122
112
|
|
|
123
113
|
self.setupViews()
|
|
124
114
|
}
|
|
@@ -138,7 +128,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
138
128
|
return
|
|
139
129
|
}
|
|
140
130
|
|
|
141
|
-
|
|
131
|
+
print("loginMagicToken received token")
|
|
142
132
|
currentToken = token
|
|
143
133
|
tokenWaitSemaphore?.signal()
|
|
144
134
|
call.resolve()
|
|
@@ -153,17 +143,17 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
153
143
|
guard let self = self else { return }
|
|
154
144
|
Task {
|
|
155
145
|
do {
|
|
156
|
-
|
|
146
|
+
print("Setting up token subscription")
|
|
157
147
|
try self.requireInitialized()
|
|
158
148
|
if let lastVoIPToken = self.lastVoIPToken, !lastVoIPToken.isEmpty {
|
|
159
|
-
|
|
149
|
+
print("Deleting device: \(lastVoIPToken)")
|
|
160
150
|
try await self.streamVideo?.deleteDevice(id: lastVoIPToken)
|
|
161
151
|
}
|
|
162
152
|
if !updatedDeviceToken.isEmpty {
|
|
163
|
-
|
|
153
|
+
print("Setting voip device: \(updatedDeviceToken)")
|
|
164
154
|
try await self.streamVideo?.setVoipDevice(id: updatedDeviceToken)
|
|
165
155
|
// Save the token to our secure storage
|
|
166
|
-
|
|
156
|
+
print("Saving voip token: \(updatedDeviceToken)")
|
|
167
157
|
SecureUserRepository.shared.save(voipPushToken: updatedDeviceToken)
|
|
168
158
|
}
|
|
169
159
|
self.lastVoIPToken = updatedDeviceToken
|
|
@@ -185,7 +175,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
185
175
|
|
|
186
176
|
// Verify callViewModel exists
|
|
187
177
|
guard let callViewModel = self.callViewModel, let streamVideo = self.streamVideo else {
|
|
188
|
-
|
|
178
|
+
print("Warning: setupActiveCallSubscription called but callViewModel or streamVideo is nil")
|
|
189
179
|
// Schedule a retry after a short delay if callViewModel is nil
|
|
190
180
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { [weak self] in
|
|
191
181
|
self?.setupActiveCallSubscription()
|
|
@@ -193,7 +183,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
193
183
|
return
|
|
194
184
|
}
|
|
195
185
|
|
|
196
|
-
|
|
186
|
+
print("Setting up active call subscription")
|
|
197
187
|
|
|
198
188
|
// Create a strong reference to callViewModel to ensure it's not deallocated
|
|
199
189
|
// while the subscription is active
|
|
@@ -205,7 +195,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
205
195
|
.sink { [weak self, weak viewModel] activeCall in
|
|
206
196
|
guard let self = self, let viewModel = viewModel else { return }
|
|
207
197
|
|
|
208
|
-
|
|
198
|
+
print("Active call update from streamVideo: \(String(describing: activeCall?.cId))")
|
|
209
199
|
|
|
210
200
|
if let activeCall = activeCall {
|
|
211
201
|
// Sync callViewModel with activeCall from streamVideo state
|
|
@@ -222,24 +212,24 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
222
212
|
.receive(on: DispatchQueue.main)
|
|
223
213
|
.sink { [weak self, weak viewModel] newState in
|
|
224
214
|
guard let self = self, let viewModel = viewModel else {
|
|
225
|
-
|
|
215
|
+
print("Warning: Call state update received but self or viewModel is nil")
|
|
226
216
|
return
|
|
227
217
|
}
|
|
228
218
|
|
|
229
219
|
do {
|
|
230
220
|
try self.requireInitialized()
|
|
231
|
-
|
|
221
|
+
print("Call State Update: \(newState)")
|
|
232
222
|
|
|
233
223
|
if newState == .inCall {
|
|
234
|
-
|
|
235
|
-
|
|
224
|
+
print("- In call state detected")
|
|
225
|
+
print("- All participants: \(String(describing: viewModel.participants))")
|
|
236
226
|
|
|
237
227
|
// Create/update overlay and make visible when there's an active call
|
|
238
228
|
self.createCallOverlayView()
|
|
239
229
|
|
|
240
230
|
// Notify that a call has started - but only if we haven't notified for this call yet
|
|
241
231
|
if let callId = viewModel.call?.cId, !self.hasNotifiedCallJoined || callId != self.currentCallId {
|
|
242
|
-
|
|
232
|
+
print("Notifying call joined: \(callId)")
|
|
243
233
|
self.updateCallStatusAndNotify(callId: callId, state: "joined")
|
|
244
234
|
self.hasNotifiedCallJoined = true
|
|
245
235
|
}
|
|
@@ -248,7 +238,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
248
238
|
} else if newState == .idle && self.streamVideo?.state.activeCall == nil {
|
|
249
239
|
// Get the call ID that was active before the state changed
|
|
250
240
|
let endingCallId = viewModel.call?.cId
|
|
251
|
-
|
|
241
|
+
print("Call ending: \(String(describing: endingCallId))")
|
|
252
242
|
|
|
253
243
|
// Notify that call has ended - use the properly tracked call ID
|
|
254
244
|
self.updateCallStatusAndNotify(callId: endingCallId ?? "", state: "left")
|
|
@@ -264,7 +254,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
264
254
|
// Remove call from callStates
|
|
265
255
|
self.callStates.removeValue(forKey: callCid)
|
|
266
256
|
|
|
267
|
-
|
|
257
|
+
print("Cleaned up resources for ended call: \(callCid)")
|
|
268
258
|
}
|
|
269
259
|
|
|
270
260
|
// Remove the call overlay view when not in a call
|
|
@@ -281,7 +271,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
281
271
|
statePublisher.cancel()
|
|
282
272
|
}
|
|
283
273
|
|
|
284
|
-
|
|
274
|
+
print("Active call subscription setup completed")
|
|
285
275
|
|
|
286
276
|
// Schedule a periodic check to ensure subscription is active
|
|
287
277
|
self.scheduleSubscriptionCheck()
|
|
@@ -296,7 +286,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
296
286
|
|
|
297
287
|
// Check if we're in a state where we need the subscription but it's not active
|
|
298
288
|
if self.state == .initialized && self.activeCallSubscription == nil && self.callViewModel != nil {
|
|
299
|
-
|
|
289
|
+
print("Subscription check: Restoring lost activeCallSubscription")
|
|
300
290
|
self.setupActiveCallSubscription()
|
|
301
291
|
} else {
|
|
302
292
|
// Schedule the next check
|
|
@@ -333,8 +323,8 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
333
323
|
let hasAccepted = callState.participantResponses.values.contains { $0 == "accepted" }
|
|
334
324
|
|
|
335
325
|
if !hasAccepted {
|
|
336
|
-
|
|
337
|
-
|
|
326
|
+
print("Call \(callCid) has timed out after \(elapsedSeconds) seconds")
|
|
327
|
+
print("No one accepted call \(callCid), marking all non-responders as missed")
|
|
338
328
|
|
|
339
329
|
// Mark all members who haven't responded as "missed"
|
|
340
330
|
for member in callState.members {
|
|
@@ -396,21 +386,21 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
396
386
|
}
|
|
397
387
|
|
|
398
388
|
guard let callState = callState else {
|
|
399
|
-
|
|
389
|
+
print("Call state not found for cId: \(callCid)")
|
|
400
390
|
return
|
|
401
391
|
}
|
|
402
392
|
|
|
403
393
|
let totalParticipants = callState.members.count
|
|
404
394
|
let responseCount = callState.participantResponses.count
|
|
405
395
|
|
|
406
|
-
|
|
396
|
+
print("Total participants: \(totalParticipants), Responses: \(responseCount)")
|
|
407
397
|
|
|
408
398
|
let allResponded = responseCount >= totalParticipants
|
|
409
399
|
let allRejectedOrMissed = allResponded &&
|
|
410
400
|
callState.participantResponses.values.allSatisfy { $0 == "rejected" || $0 == "missed" }
|
|
411
401
|
|
|
412
402
|
if allResponded && allRejectedOrMissed {
|
|
413
|
-
|
|
403
|
+
print("All participants have rejected or missed the call")
|
|
414
404
|
|
|
415
405
|
// End the call
|
|
416
406
|
if let call = streamVideo?.state.activeCall, call.cId == callCid {
|
|
@@ -554,18 +544,18 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
554
544
|
|
|
555
545
|
Task {
|
|
556
546
|
do {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
547
|
+
print("Creating call:")
|
|
548
|
+
print("- Call ID: \(callId)")
|
|
549
|
+
print("- Call Type: \(callType)")
|
|
550
|
+
print("- Users: \(members)")
|
|
551
|
+
print("- Should Ring: \(shouldRing)")
|
|
552
|
+
print("- Team: \(team)")
|
|
563
553
|
|
|
564
554
|
// Create the call object
|
|
565
555
|
let streamCall = streamVideo?.call(callType: callType, callId: callId)
|
|
566
556
|
|
|
567
557
|
// Start the call with the members
|
|
568
|
-
|
|
558
|
+
print("Creating call with members...")
|
|
569
559
|
try await streamCall?.create(
|
|
570
560
|
memberIds: members,
|
|
571
561
|
custom: [:],
|
|
@@ -573,9 +563,9 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
573
563
|
)
|
|
574
564
|
|
|
575
565
|
// Join the call
|
|
576
|
-
|
|
566
|
+
print("Joining call...")
|
|
577
567
|
try await streamCall?.join(create: false)
|
|
578
|
-
|
|
568
|
+
print("Successfully joined call")
|
|
579
569
|
|
|
580
570
|
// Update the CallOverlayView with the active call
|
|
581
571
|
await MainActor.run {
|
|
@@ -705,14 +695,14 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
705
695
|
}
|
|
706
696
|
|
|
707
697
|
// Join the call
|
|
708
|
-
|
|
698
|
+
print("Accepting and joining call \(streamCall!.cId)...")
|
|
709
699
|
guard case .incoming(let incomingCall) = await self.callViewModel?.callingState else {
|
|
710
700
|
call.reject("Failed to accept call as there is no call ID")
|
|
711
701
|
return
|
|
712
702
|
}
|
|
713
703
|
|
|
714
704
|
await self.callViewModel?.acceptCall(callType: incomingCall.type, callId: incomingCall.id)
|
|
715
|
-
|
|
705
|
+
print("Successfully joined call")
|
|
716
706
|
|
|
717
707
|
// Update the CallOverlayView with the active call
|
|
718
708
|
await MainActor.run {
|
|
@@ -736,18 +726,18 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
736
726
|
|
|
737
727
|
private func initializeStreamVideo() {
|
|
738
728
|
if (state == .initialized) {
|
|
739
|
-
|
|
729
|
+
print("initializeStreamVideo already initialized")
|
|
740
730
|
// Try to get user credentials from repository
|
|
741
731
|
guard let savedCredentials = SecureUserRepository.shared.loadCurrentUser() else {
|
|
742
|
-
|
|
732
|
+
print("Save credentials not found, skipping initialization")
|
|
743
733
|
return
|
|
744
734
|
}
|
|
745
735
|
if (savedCredentials.user.id == streamVideo?.user.id) {
|
|
746
|
-
|
|
736
|
+
print("Skipping initializeStreamVideo as user is already logged in")
|
|
747
737
|
return
|
|
748
738
|
}
|
|
749
739
|
} else if (state == .initializing) {
|
|
750
|
-
|
|
740
|
+
print("initializeStreamVideo rejected - already initializing")
|
|
751
741
|
return
|
|
752
742
|
}
|
|
753
743
|
state = .initializing
|
|
@@ -755,11 +745,11 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
755
745
|
// Try to get user credentials from repository
|
|
756
746
|
guard let savedCredentials = SecureUserRepository.shared.loadCurrentUser(),
|
|
757
747
|
let apiKey = self.apiKey else {
|
|
758
|
-
|
|
748
|
+
print("No saved credentials or API key found, skipping initialization")
|
|
759
749
|
state = .notInitialized
|
|
760
750
|
return
|
|
761
751
|
}
|
|
762
|
-
|
|
752
|
+
print("Initializing with saved credentials for user: \(savedCredentials.user.name)")
|
|
763
753
|
|
|
764
754
|
LogConfig.level = .debug
|
|
765
755
|
self.streamVideo = StreamVideo(
|
|
@@ -768,7 +758,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
768
758
|
token: UserToken(stringLiteral: savedCredentials.tokenValue),
|
|
769
759
|
tokenProvider: {completion in
|
|
770
760
|
guard let savedCredentials = SecureUserRepository.shared.loadCurrentUser() else {
|
|
771
|
-
|
|
761
|
+
print("No saved credentials or API key found, cannot refresh token")
|
|
772
762
|
|
|
773
763
|
completion(.failure(NSError(domain: "No saved credentials or API key found, cannot refresh token", code: 0, userInfo: nil)))
|
|
774
764
|
return
|
|
@@ -861,7 +851,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
861
851
|
|
|
862
852
|
// Check if we already have an overlay view - do nothing if it exists
|
|
863
853
|
if let existingOverlayView = self.overlayView, existingOverlayView.superview != nil {
|
|
864
|
-
|
|
854
|
+
print("Call overlay view already exists, making it visible")
|
|
865
855
|
existingOverlayView.isHidden = false
|
|
866
856
|
// Make webview transparent to see StreamCall UI underneath
|
|
867
857
|
webView.isOpaque = false
|
|
@@ -870,7 +860,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
870
860
|
return
|
|
871
861
|
}
|
|
872
862
|
|
|
873
|
-
|
|
863
|
+
print("Creating new call overlay view")
|
|
874
864
|
|
|
875
865
|
// First, create the overlay view
|
|
876
866
|
let overlayView = UIHostingController(rootView: CallOverlayView(viewModel: callOverlayView))
|
|
@@ -923,7 +913,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
923
913
|
private func ensureViewRemoved() {
|
|
924
914
|
// Check if we have an overlay view
|
|
925
915
|
if let existingOverlayView = self.overlayView {
|
|
926
|
-
|
|
916
|
+
print("Hiding call overlay view")
|
|
927
917
|
|
|
928
918
|
// Hide the view instead of removing it
|
|
929
919
|
existingOverlayView.isHidden = true
|
|
@@ -933,7 +923,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
933
923
|
self.webView?.backgroundColor = nil
|
|
934
924
|
self.webView?.scrollView.backgroundColor = nil
|
|
935
925
|
} else {
|
|
936
|
-
|
|
926
|
+
print("No call overlay view to hide")
|
|
937
927
|
}
|
|
938
928
|
}
|
|
939
929
|
|
package/package.json
CHANGED