@capgo/capacitor-stream-call 0.0.71 → 0.0.78
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/README.md +61 -12
- package/android/build.gradle +4 -4
- package/android/src/main/java/ee/forgr/capacitor/streamcall/CustomNotificationHandler.kt +60 -0
- package/android/src/main/java/ee/forgr/capacitor/streamcall/JSObjectExtension.kt +38 -0
- package/android/src/main/java/ee/forgr/capacitor/streamcall/StreamCallPlugin.kt +118 -7
- package/dist/docs.json +124 -0
- package/dist/esm/definitions.d.ts +38 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +5 -1
- package/dist/esm/web.js +6 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +6 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +6 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/StreamCallPlugin/StreamCallPlugin.swift +123 -6
- package/package.json +1 -1
|
@@ -27,7 +27,9 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
27
27
|
CAPPluginMethod(name: "getCallStatus", returnType: CAPPluginReturnPromise),
|
|
28
28
|
CAPPluginMethod(name: "setSpeaker", returnType: CAPPluginReturnPromise),
|
|
29
29
|
CAPPluginMethod(name: "switchCamera", returnType: CAPPluginReturnPromise),
|
|
30
|
-
CAPPluginMethod(name: "getCallInfo", returnType: CAPPluginReturnPromise)
|
|
30
|
+
CAPPluginMethod(name: "getCallInfo", returnType: CAPPluginReturnPromise),
|
|
31
|
+
CAPPluginMethod(name: "setDynamicStreamVideoApikey", returnType: CAPPluginReturnPromise),
|
|
32
|
+
CAPPluginMethod(name: "getDynamicStreamVideoApikey", returnType: CAPPluginReturnPromise)
|
|
31
33
|
]
|
|
32
34
|
|
|
33
35
|
private enum State {
|
|
@@ -62,6 +64,9 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
62
64
|
|
|
63
65
|
// Declare as optional and initialize in load() method
|
|
64
66
|
private var callViewModel: CallViewModel?
|
|
67
|
+
|
|
68
|
+
// Constants for UserDefaults keys
|
|
69
|
+
private let dynamicApiKeyKey = "stream.video.dynamic.apikey"
|
|
65
70
|
|
|
66
71
|
// Helper method to update call status and notify listeners
|
|
67
72
|
private func updateCallStatusAndNotify(callId: String, state: String, userId: String? = nil, reason: String? = nil, caller: [String: Any]? = nil, members: [[String: Any]]? = nil) {
|
|
@@ -474,6 +479,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
474
479
|
let shouldRing = call.getBool("ring") ?? true
|
|
475
480
|
let team = call.getString("team")
|
|
476
481
|
let video = call.getBool("video") ?? false
|
|
482
|
+
let custom = call.getObject("custom")
|
|
477
483
|
|
|
478
484
|
// Generate a unique call ID
|
|
479
485
|
let callId = UUID().uuidString
|
|
@@ -491,7 +497,61 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
491
497
|
await self.callViewModel?.startCall(
|
|
492
498
|
callType: callType,
|
|
493
499
|
callId: callId,
|
|
494
|
-
members: members.map { Member(userId: $0, role: nil, customData: [:], updatedAt: nil) },
|
|
500
|
+
members: members.map { Member(userId: $0, role: nil, customData: [:], updatedAt: nil) },
|
|
501
|
+
team: team,
|
|
502
|
+
ring: shouldRing,
|
|
503
|
+
customData: custom?.compactMapValues { jsValue in
|
|
504
|
+
switch jsValue {
|
|
505
|
+
case let str as String:
|
|
506
|
+
return .string(str)
|
|
507
|
+
case let bool as Bool:
|
|
508
|
+
return .bool(bool)
|
|
509
|
+
case let int as Int:
|
|
510
|
+
return .number(Double(int))
|
|
511
|
+
case let float as Float:
|
|
512
|
+
return .number(Double(float))
|
|
513
|
+
case let double as Double:
|
|
514
|
+
return .number(double)
|
|
515
|
+
case let number as NSNumber:
|
|
516
|
+
return .number(number.doubleValue)
|
|
517
|
+
case is NSNull:
|
|
518
|
+
return .nil
|
|
519
|
+
case let date as Date:
|
|
520
|
+
let formatter = ISO8601DateFormatter()
|
|
521
|
+
return .string(formatter.string(from: date))
|
|
522
|
+
case let array as Array<JSValue>:
|
|
523
|
+
let mappedArray = array.compactMap { item -> RawJSON? in
|
|
524
|
+
// Recursive conversion for array elements
|
|
525
|
+
switch item {
|
|
526
|
+
case let str as String: return .string(str)
|
|
527
|
+
case let bool as Bool: return .bool(bool)
|
|
528
|
+
case let int as Int: return .number(Double(int))
|
|
529
|
+
case let double as Double: return .number(double)
|
|
530
|
+
case let number as NSNumber: return .number(number.doubleValue)
|
|
531
|
+
case is NSNull: return .nil
|
|
532
|
+
default: return .string(String(describing: item))
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return .array(mappedArray)
|
|
536
|
+
case let dict as Dictionary<String, JSValue>:
|
|
537
|
+
let mappedDict = dict.compactMapValues { value -> RawJSON? in
|
|
538
|
+
// Recursive conversion for dictionary values
|
|
539
|
+
switch value {
|
|
540
|
+
case let str as String: return .string(str)
|
|
541
|
+
case let bool as Bool: return .bool(bool)
|
|
542
|
+
case let int as Int: return .number(Double(int))
|
|
543
|
+
case let double as Double: return .number(double)
|
|
544
|
+
case let number as NSNumber: return .number(number.doubleValue)
|
|
545
|
+
case is NSNull: return .nil
|
|
546
|
+
default: return .string(String(describing: value))
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return .dictionary(mappedDict)
|
|
550
|
+
default:
|
|
551
|
+
return .string(String(describing: jsValue))
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
video: video
|
|
495
555
|
)
|
|
496
556
|
|
|
497
557
|
// Wait for call state to be populated by WebSocket events
|
|
@@ -780,7 +840,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
780
840
|
|
|
781
841
|
// Try to get user credentials from repository
|
|
782
842
|
guard let savedCredentials = SecureUserRepository.shared.loadCurrentUser(),
|
|
783
|
-
let apiKey =
|
|
843
|
+
let apiKey = getEffectiveApiKey() else {
|
|
784
844
|
print("No saved credentials or API key found, skipping initialization")
|
|
785
845
|
state = .notInitialized
|
|
786
846
|
return
|
|
@@ -972,8 +1032,34 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
972
1032
|
])
|
|
973
1033
|
}
|
|
974
1034
|
}
|
|
975
|
-
|
|
976
|
-
|
|
1035
|
+
|
|
1036
|
+
// MARK: - Dynamic API Key Management
|
|
1037
|
+
|
|
1038
|
+
func saveDynamicApiKey(_ apiKey: String) {
|
|
1039
|
+
UserDefaults.standard.set(apiKey, forKey: dynamicApiKeyKey)
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
func getDynamicApiKey() -> String? {
|
|
1043
|
+
return UserDefaults.standard.string(forKey: dynamicApiKeyKey)
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
func clearDynamicApiKey() {
|
|
1047
|
+
UserDefaults.standard.removeObject(forKey: dynamicApiKeyKey)
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
func getEffectiveApiKey() -> String? {
|
|
1051
|
+
// A) Check if the key exists in UserDefaults
|
|
1052
|
+
if let dynamicApiKey = getDynamicApiKey(), !dynamicApiKey.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).isEmpty {
|
|
1053
|
+
print("Using dynamic API key")
|
|
1054
|
+
return dynamicApiKey
|
|
1055
|
+
} else {
|
|
1056
|
+
// B) If not, use static API key from Info.plist
|
|
1057
|
+
print("Using static API key from Info.plist")
|
|
1058
|
+
return self.apiKey
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
func ensureViewRemoved() {
|
|
977
1063
|
// Disable touch interceptor when overlay is removed
|
|
978
1064
|
self.touchInterceptView?.setCallActive(false)
|
|
979
1065
|
|
|
@@ -1120,7 +1206,7 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1120
1206
|
call.reject("StreamVideo not initialized")
|
|
1121
1207
|
}
|
|
1122
1208
|
}
|
|
1123
|
-
|
|
1209
|
+
|
|
1124
1210
|
@objc func switchCamera(_ call: CAPPluginCall) {
|
|
1125
1211
|
guard let camera = call.getString("camera") else {
|
|
1126
1212
|
call.reject("Missing required parameter: camera")
|
|
@@ -1150,5 +1236,36 @@ public class StreamCallPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1150
1236
|
call.reject("StreamVideo not initialized")
|
|
1151
1237
|
}
|
|
1152
1238
|
}
|
|
1239
|
+
|
|
1240
|
+
@objc func setDynamicStreamVideoApikey(_ call: CAPPluginCall) {
|
|
1241
|
+
guard let apiKey = call.getString("apiKey") else {
|
|
1242
|
+
call.reject("Missing required parameter: apiKey")
|
|
1243
|
+
return
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
do {
|
|
1247
|
+
saveDynamicApiKey(apiKey)
|
|
1248
|
+
print("Dynamic API key saved successfully")
|
|
1249
|
+
call.resolve([
|
|
1250
|
+
"success": true
|
|
1251
|
+
])
|
|
1252
|
+
} catch {
|
|
1253
|
+
print("Error saving dynamic API key: \(error)")
|
|
1254
|
+
call.reject("Failed to save API key: \(error.localizedDescription)")
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
@objc func getDynamicStreamVideoApikey(_ call: CAPPluginCall) {
|
|
1259
|
+
do {
|
|
1260
|
+
let apiKey = getDynamicApiKey()
|
|
1261
|
+
call.resolve([
|
|
1262
|
+
"apiKey": apiKey as Any,
|
|
1263
|
+
"hasDynamicKey": apiKey != nil && !apiKey!.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).isEmpty
|
|
1264
|
+
])
|
|
1265
|
+
} catch {
|
|
1266
|
+
print("Error getting dynamic API key: \(error)")
|
|
1267
|
+
call.reject("Failed to get API key: \(error.localizedDescription)")
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1153
1270
|
|
|
1154
1271
|
}
|
package/package.json
CHANGED