@poolse/native 3.8.0 → 3.10.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.
- package/CHANGELOG.md +55 -0
- package/README.md +127 -9
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/dev/poolse/callcore/CallCoreRuntime.kt +8 -0
- package/android/src/main/java/dev/poolse/callcore/Ports.kt +47 -1
- package/android/src/main/java/dev/poolse/callcore/android/AndroidRingSurface.kt +3 -3
- package/android/src/main/java/dev/poolse/callcore/android/CallCore.kt +112 -10
- package/android/src/main/java/dev/poolse/callcore/android/CallHttpClient.kt +3 -0
- package/android/src/main/java/dev/poolse/callcore/android/CallMessagingService.kt +21 -1
- package/android/src/main/java/dev/poolse/callcore/android/CallVideo.kt +14 -0
- package/android/src/main/java/dev/poolse/callcore/android/EscalationNotification.kt +475 -0
- package/android/src/main/java/dev/poolse/callcore/android/IncomingCallActivity.kt +9 -4
- package/android/src/main/java/dev/poolse/callcore/android/MeetingNotification.kt +127 -0
- package/android/src/main/java/dev/poolse/callcore/android/PoolseIncomingCall.kt +9 -0
- package/android/src/main/java/dev/poolse/callcore/android/RingBundle.kt +9 -0
- package/android/src/main/java/dev/poolse/callcore/android/SnapshotJson.kt +23 -0
- package/android/src/main/java/expo/modules/poolsecalls/PoolseCallsModule.kt +17 -1
- package/android/src/main/livekit/java/dev/poolse/callcore/livekit/LiveKitMediaPort.kt +174 -11
- package/dist/index.cjs +33 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +197 -23
- package/dist/index.d.ts +197 -23
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/ios/Core/CallCoreRuntime.swift +8 -0
- package/ios/Core/CallHttpClient.swift +11 -1
- package/ios/Core/Ports.swift +47 -2
- package/ios/Core/SnapshotEncoding.swift +39 -4
- package/ios/Module/PoolseCallsModule.swift +28 -1
- package/ios/Platform/CallCore.swift +68 -2
- package/ios/Platform/CallKitController.swift +1 -1
- package/ios/Platform/EscalationNotifications.swift +195 -0
- package/ios/Platform/LiveKitMediaPort.swift +178 -15
- package/ios/Platform/MessageNotifications.swift +60 -1
- package/ios/Platform/VoipPush.swift +11 -2
- package/package.json +1 -1
- package/src/index.ts +231 -23
|
@@ -32,6 +32,12 @@ protocol MediaEvents: AnyObject {
|
|
|
32
32
|
/// Our own link to the SFU (`good` | `poor` | `lost` | `unknown`), and
|
|
33
33
|
/// whether incoming video is paused to keep the audio going.
|
|
34
34
|
func onNetwork(quality: String, videoPaused: Bool)
|
|
35
|
+
/// Whether the server lets us publish (false: recording consent not
|
|
36
|
+
/// given yet, docs/RECORDING.md §5). Sent on every change.
|
|
37
|
+
func onCanPublish(_ allowed: Bool)
|
|
38
|
+
/// The SFU replaced us with the same user joining from another device
|
|
39
|
+
/// ("move call to this device", CALL_CONTRACT.md §9). Sent just before `onLost`.
|
|
40
|
+
func onMovedElsewhere()
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
/// Step-by-step trace of the audio path, in the device log as
|
|
@@ -93,6 +99,11 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
93
99
|
private var mutedWanted = false
|
|
94
100
|
private var cameraWanted: Bool?
|
|
95
101
|
private var joinedCallId: String?
|
|
102
|
+
/// The server lets us publish. False while it holds our media back for
|
|
103
|
+
/// consent: the mic/camera choices above are kept, nothing is published
|
|
104
|
+
/// (LiveKit unpublished what was live), and they come back as they were
|
|
105
|
+
/// once permission returns.
|
|
106
|
+
private var canPublish = true
|
|
96
107
|
|
|
97
108
|
/// Our own link to the SFU, as last reported.
|
|
98
109
|
private var localQuality = "unknown"
|
|
@@ -105,6 +116,12 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
105
116
|
private static let pauseVideoAfter: TimeInterval = 6
|
|
106
117
|
private static let resumeVideoAfter: TimeInterval = 10
|
|
107
118
|
|
|
119
|
+
/// Capture processing (CL7); per process, not per call.
|
|
120
|
+
private(set) var noiseSuppression = true
|
|
121
|
+
private(set) var backgroundBlur = false
|
|
122
|
+
/// The capturer holds its processor weakly: this keeps it alive.
|
|
123
|
+
private var blurProcessor: BackgroundBlurVideoProcessor?
|
|
124
|
+
|
|
108
125
|
private let surfaces = NSHashTable<LiveKitVideoSurface>.weakObjects()
|
|
109
126
|
private var audioPrepared = false
|
|
110
127
|
private var audioActive = false
|
|
@@ -267,9 +284,14 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
267
284
|
}
|
|
268
285
|
let muted = await MainActor.run { self.mutedWanted }
|
|
269
286
|
let activeNow = await MainActor.run { self.audioActive }
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
287
|
+
// The token may say listen-only (consent required, not yet given):
|
|
288
|
+
// publish nothing then — the permission update brings it back.
|
|
289
|
+
let allowed = await MainActor.run { self.updateCanPublish(r) }
|
|
290
|
+
pcTrace("connected; publishing mic muted=\(muted) audioActive=\(activeNow) canPublish=\(allowed)")
|
|
291
|
+
if allowed {
|
|
292
|
+
do { try await r.localParticipant.setMicrophone(enabled: !muted) } catch {
|
|
293
|
+
NSLog("[PoolseCalls] microphone publish failed: %@", "\(error)")
|
|
294
|
+
}
|
|
273
295
|
}
|
|
274
296
|
// Connected and publishing: make sure nothing changed the session
|
|
275
297
|
pcTrace("mic published enabled=\(r.localParticipant.isMicrophoneEnabled()) \(pcSessionDescription())")
|
|
@@ -280,7 +302,7 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
280
302
|
self.ensureAudioActivated(r, attempt: 0)
|
|
281
303
|
}
|
|
282
304
|
let camera = await MainActor.run { self.cameraWanted ?? wantsVideo }
|
|
283
|
-
if camera { await self.enableCamera(r, true) }
|
|
305
|
+
if camera && allowed { await self.enableCamera(r, true) }
|
|
284
306
|
await MainActor.run {
|
|
285
307
|
self.reportLocalCamera(r)
|
|
286
308
|
self.refreshVideo()
|
|
@@ -294,7 +316,7 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
294
316
|
connectedRoom = ObjectIdentifier(r)
|
|
295
317
|
if outputWanted != nil { applyRoute() }
|
|
296
318
|
events?.onConnected()
|
|
297
|
-
if !r.
|
|
319
|
+
if !people(r).isEmpty { events?.onRemoteJoined() }
|
|
298
320
|
emit(r)
|
|
299
321
|
refreshVideo()
|
|
300
322
|
}
|
|
@@ -326,6 +348,7 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
326
348
|
private func resetWanted() {
|
|
327
349
|
mutedWanted = false
|
|
328
350
|
cameraWanted = nil
|
|
351
|
+
canPublish = true
|
|
329
352
|
outputWanted = nil
|
|
330
353
|
pauseWork?.cancel()
|
|
331
354
|
resumeWork?.cancel()
|
|
@@ -369,7 +392,7 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
369
392
|
/// broadcast ends, from here or from the status bar), so the snapshot
|
|
370
393
|
/// follows the real state rather than the request.
|
|
371
394
|
func setScreenShare(_ on: Bool) {
|
|
372
|
-
guard let r = room, connectedRoom == ObjectIdentifier(r) else { return }
|
|
395
|
+
guard let r = room, connectedRoom == ObjectIdentifier(r), canPublish || !on else { return }
|
|
373
396
|
if !on, BroadcastManager.shared.isBroadcasting { BroadcastManager.shared.requestStop() }
|
|
374
397
|
Task { [weak self] in
|
|
375
398
|
do { _ = try await r.localParticipant.setScreenShare(enabled: on) } catch {
|
|
@@ -389,13 +412,14 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
389
412
|
|
|
390
413
|
func setMuted(_ muted: Bool) {
|
|
391
414
|
mutedWanted = muted
|
|
392
|
-
|
|
415
|
+
// Not allowed to publish: only remembered, applied on republish.
|
|
416
|
+
guard let r = room, connectedRoom == ObjectIdentifier(r), canPublish else { return }
|
|
393
417
|
Task { _ = try? await r.localParticipant.setMicrophone(enabled: !muted) }
|
|
394
418
|
}
|
|
395
419
|
|
|
396
420
|
func setCamera(_ on: Bool) {
|
|
397
421
|
cameraWanted = on
|
|
398
|
-
guard let r = room, connectedRoom == ObjectIdentifier(r) else { return }
|
|
422
|
+
guard let r = room, connectedRoom == ObjectIdentifier(r), canPublish else { return }
|
|
399
423
|
Task { [weak self] in
|
|
400
424
|
await self?.enableCamera(r, on)
|
|
401
425
|
await MainActor.run {
|
|
@@ -406,6 +430,55 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
406
430
|
}
|
|
407
431
|
}
|
|
408
432
|
|
|
433
|
+
// MARK: - publish permission (recording consent)
|
|
434
|
+
|
|
435
|
+
/// Reads the local participant's permission; reports a change. Returns it.
|
|
436
|
+
@discardableResult
|
|
437
|
+
private func updateCanPublish(_ r: Room) -> Bool {
|
|
438
|
+
guard room === r else { return canPublish }
|
|
439
|
+
let now = r.localParticipant.permissions.canPublish
|
|
440
|
+
if now != canPublish {
|
|
441
|
+
canPublish = now
|
|
442
|
+
pcTrace("canPublish=\(now)")
|
|
443
|
+
events?.onCanPublish(now)
|
|
444
|
+
}
|
|
445
|
+
return now
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/// The server changed what we may do. Revoked: LiveKit has unpublished
|
|
449
|
+
/// our tracks itself — nothing to do but say so. Back: publish the mic
|
|
450
|
+
/// and camera the way the user last had them.
|
|
451
|
+
fileprivate func permissionsChanged(_ r: Room) {
|
|
452
|
+
guard room === r, connectedRoom == ObjectIdentifier(r) else { return }
|
|
453
|
+
let was = canPublish
|
|
454
|
+
if updateCanPublish(r) && !was { republish() }
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/// Mic and camera as the user last had them — after consent (the app
|
|
458
|
+
/// calls this from its consent prompt; the permission update does it
|
|
459
|
+
/// too). A no-op while the server still says listen-only.
|
|
460
|
+
func republish() {
|
|
461
|
+
guard let r = room, connectedRoom == ObjectIdentifier(r), updateCanPublish(r) else { return }
|
|
462
|
+
let muted = mutedWanted
|
|
463
|
+
let camera = cameraWanted ?? (media == "video")
|
|
464
|
+
pcTrace("republish muted=\(muted) camera=\(camera)")
|
|
465
|
+
Task { [weak self] in
|
|
466
|
+
if r.localParticipant.isMicrophoneEnabled() != !muted {
|
|
467
|
+
do { try await r.localParticipant.setMicrophone(enabled: !muted) } catch {
|
|
468
|
+
NSLog("[PoolseCalls] microphone republish failed: %@", "\(error)")
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
guard let self = self else { return }
|
|
472
|
+
let cameraLive = await MainActor.run { self.room === r && self.localCameraTrack(r) != nil }
|
|
473
|
+
if camera && !cameraLive { await self.enableCamera(r, true) }
|
|
474
|
+
await MainActor.run {
|
|
475
|
+
guard self.room === r else { return }
|
|
476
|
+
self.reportLocalCamera(r)
|
|
477
|
+
self.refreshVideo()
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
409
482
|
func switchCamera() {
|
|
410
483
|
guard let r = room, let track = localCameraTrack(r), let capturer = track.capturer as? CameraCapturer else { return }
|
|
411
484
|
Task { [weak self] in
|
|
@@ -640,7 +713,7 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
640
713
|
guard let r = room else { return nil }
|
|
641
714
|
if local { return localCameraTrack(r) }
|
|
642
715
|
guard let id = participantId,
|
|
643
|
-
let p = r.
|
|
716
|
+
let p = people(r).first(where: { $0.identity?.stringValue == id }) else { return nil }
|
|
644
717
|
return remoteCamera(p)
|
|
645
718
|
}
|
|
646
719
|
|
|
@@ -662,7 +735,7 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
662
735
|
return pub.track as? VideoTrack
|
|
663
736
|
}
|
|
664
737
|
guard let id = participantId,
|
|
665
|
-
let p = r.
|
|
738
|
+
let p = people(r).first(where: { $0.identity?.stringValue == id }) else { return nil }
|
|
666
739
|
return remoteScreen(p)
|
|
667
740
|
}
|
|
668
741
|
|
|
@@ -678,8 +751,37 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
678
751
|
return (track.capturer as? CameraCapturer)?.position == .back ? "back" : "front"
|
|
679
752
|
}
|
|
680
753
|
|
|
754
|
+
// MARK: - capture processing (CL7)
|
|
755
|
+
|
|
756
|
+
/// Apple's voice processing (VPIO) does echo cancellation, gain control
|
|
757
|
+
/// and noise suppression as one unit, so "off" bypasses all of it —
|
|
758
|
+
/// meant for headphones (music, an instrument). Valid mid-call.
|
|
759
|
+
func setNoiseSuppression(_ on: Bool) {
|
|
760
|
+
noiseSuppression = on
|
|
761
|
+
AudioManager.shared.isVoiceProcessingBypassed = !on
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/// Blur behind the person on the published camera (Vision person
|
|
765
|
+
/// segmentation, LiveKit's BackgroundBlurVideoProcessor). Survives a
|
|
766
|
+
/// camera flip and republish: re-applied whenever the camera is reported.
|
|
767
|
+
func setBackgroundBlur(_ on: Bool) {
|
|
768
|
+
backgroundBlur = on
|
|
769
|
+
if let r = room { applyBlur(r) }
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
private func applyBlur(_ r: Room) {
|
|
773
|
+
guard let track = localCameraTrack(r) else { return }
|
|
774
|
+
if backgroundBlur {
|
|
775
|
+
if blurProcessor == nil { blurProcessor = BackgroundBlurVideoProcessor() }
|
|
776
|
+
if track.capturer.processor !== blurProcessor { track.capturer.processor = blurProcessor }
|
|
777
|
+
} else if track.capturer.processor != nil {
|
|
778
|
+
track.capturer.processor = nil
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
681
782
|
private func reportLocalCamera(_ r: Room) {
|
|
682
783
|
guard room === r else { return }
|
|
784
|
+
applyBlur(r)
|
|
683
785
|
let on = localCameraTrack(r) != nil
|
|
684
786
|
events?.onLocalCamera(on: on, facing: on ? cameraFacing() : nil)
|
|
685
787
|
}
|
|
@@ -696,9 +798,14 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
696
798
|
case .reconnected:
|
|
697
799
|
events?.onRecovered()
|
|
698
800
|
case .disconnected:
|
|
801
|
+
// The same user joined from another device: LiveKit replaces the
|
|
802
|
+
// older participant (one identity per user). The reconnect that
|
|
803
|
+
// follows is refused, and the call ends as moved.
|
|
804
|
+
if r.disconnectError?.type == .duplicateIdentity { events?.onMovedElsewhere() }
|
|
699
805
|
events?.onLost()
|
|
700
806
|
case .participantJoined:
|
|
701
|
-
|
|
807
|
+
// The transcript assistant or the recorder joining is nobody answering.
|
|
808
|
+
if !people(r).isEmpty { events?.onRemoteJoined() }
|
|
702
809
|
emit(r)
|
|
703
810
|
refreshVideo()
|
|
704
811
|
case .tracksChanged:
|
|
@@ -712,6 +819,8 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
712
819
|
case .quality:
|
|
713
820
|
qualityChanged(r)
|
|
714
821
|
emit(r)
|
|
822
|
+
case .permissions:
|
|
823
|
+
permissionsChanged(r)
|
|
715
824
|
}
|
|
716
825
|
}
|
|
717
826
|
|
|
@@ -765,7 +874,7 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
765
874
|
}
|
|
766
875
|
|
|
767
876
|
private func hasRemoteVideo(_ r: Room) -> Bool {
|
|
768
|
-
r.
|
|
877
|
+
people(r).contains { p in p.trackPublications.values.contains { $0.source == .camera } }
|
|
769
878
|
}
|
|
770
879
|
|
|
771
880
|
private func setVideoPaused(_ r: Room, _ paused: Bool) {
|
|
@@ -793,9 +902,59 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
793
902
|
events?.onNetwork(quality: localQuality, videoPaused: videoPaused)
|
|
794
903
|
}
|
|
795
904
|
|
|
905
|
+
/// The remote PEOPLE: poolse's transcript assistant and LiveKit Egress's
|
|
906
|
+
/// recorder are in the room but are not someone in the call — never in
|
|
907
|
+
/// the roster, the count that ends a call left alone, or a video tile.
|
|
908
|
+
/// Agents are listed separately (`agents`). Phone (SIP) participants are people.
|
|
909
|
+
private func people(_ r: Room) -> [RemoteParticipant] {
|
|
910
|
+
r.remoteParticipants.values.filter { p in
|
|
911
|
+
!ServiceParticipants.isService(identity: p.identity?.stringValue ?? "", kind: Self.kindName(p.kind)) &&
|
|
912
|
+
Self.metadata(p)?["agent"] as? Bool != true
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/// The kinds `ServiceParticipants` tells apart; nil for the rest.
|
|
917
|
+
static func kindName(_ k: Participant.Kind) -> String? {
|
|
918
|
+
if k == .agent { return "agent" }
|
|
919
|
+
if k == .egress { return "egress" }
|
|
920
|
+
if k == .sip { return "sip" }
|
|
921
|
+
return nil
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
/// Agents invited into the call (AGENTS_IN_CALLS.md §1): kind AGENT like
|
|
925
|
+
/// poolse's room assistant, but marked `agent: true` in their token
|
|
926
|
+
/// metadata — listed (with the badge), unlike the assistant and recorder.
|
|
927
|
+
private func agents(_ r: Room) -> [(RemoteParticipant, [String: Any])] {
|
|
928
|
+
r.remoteParticipants.values.compactMap { p -> (RemoteParticipant, [String: Any])? in
|
|
929
|
+
guard let m = Self.metadata(p), m["agent"] as? Bool == true else { return nil }
|
|
930
|
+
return (p, m)
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
static func metadata(_ p: Participant) -> [String: Any]? {
|
|
935
|
+
guard let m = p.metadata, let d = m.data(using: .utf8) else { return nil }
|
|
936
|
+
return (try? JSONSerialization.jsonObject(with: d)) as? [String: Any]
|
|
937
|
+
}
|
|
938
|
+
|
|
796
939
|
/// The REMOTE roster — the local participant is never included.
|
|
797
940
|
private func emit(_ r: Room) {
|
|
798
|
-
let
|
|
941
|
+
let agentRows = agents(r).map { entry -> SnapshotParticipant in
|
|
942
|
+
let (p, m) = entry
|
|
943
|
+
let identity = p.identity?.stringValue ?? ""
|
|
944
|
+
return SnapshotParticipant(
|
|
945
|
+
userId: identity,
|
|
946
|
+
externalId: externalId(p) ?? identity,
|
|
947
|
+
speaking: p.isSpeaking,
|
|
948
|
+
muted: !p.isMicrophoneEnabled(),
|
|
949
|
+
cameraOn: false,
|
|
950
|
+
connectionQuality: Self.wire(p.connectionQuality),
|
|
951
|
+
screenSharing: false,
|
|
952
|
+
isAgent: true,
|
|
953
|
+
agentLabel: (m["label"] as? String).flatMap { $0.isEmpty ? nil : $0 } ?? p.name,
|
|
954
|
+
agentMode: m["mode"] as? String
|
|
955
|
+
)
|
|
956
|
+
}
|
|
957
|
+
let roster = people(r).map { p -> SnapshotParticipant in
|
|
799
958
|
let identity = p.identity?.stringValue ?? ""
|
|
800
959
|
return SnapshotParticipant(
|
|
801
960
|
userId: identity,
|
|
@@ -807,7 +966,7 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
807
966
|
screenSharing: remoteScreen(p) != nil
|
|
808
967
|
)
|
|
809
968
|
}
|
|
810
|
-
events?.onParticipants(roster)
|
|
969
|
+
events?.onParticipants(roster + agentRows)
|
|
811
970
|
}
|
|
812
971
|
|
|
813
972
|
/// The host's own user id, if the server put it in attributes/metadata.
|
|
@@ -822,7 +981,7 @@ final class LiveKitMediaPort: NSObject, MediaPort {
|
|
|
822
981
|
|
|
823
982
|
/// LiveKit's delegate → main-thread room events for the port.
|
|
824
983
|
final class RoomObserver: NSObject, RoomDelegate, @unchecked Sendable {
|
|
825
|
-
enum Kind { case connected, reconnecting, reconnected, disconnected, participantJoined, tracksChanged, rosterChanged, quality }
|
|
984
|
+
enum Kind { case connected, reconnecting, reconnected, disconnected, participantJoined, tracksChanged, rosterChanged, quality, permissions }
|
|
826
985
|
|
|
827
986
|
private weak var port: LiveKitMediaPort?
|
|
828
987
|
private weak var room: Room?
|
|
@@ -855,4 +1014,8 @@ final class RoomObserver: NSObject, RoomDelegate, @unchecked Sendable {
|
|
|
855
1014
|
func room(_ room: Room, participant: Participant, didUpdateMetadata metadata: String?) { send(room, .rosterChanged) }
|
|
856
1015
|
func room(_ room: Room, participant: Participant, didUpdateAttributes attributes: [String: String]) { send(room, .rosterChanged) }
|
|
857
1016
|
func room(_ room: Room, participant: Participant, didUpdateConnectionQuality quality: ConnectionQuality) { send(room, .quality) }
|
|
1017
|
+
// Only ever the local participant's (LiveKit's own LocalParticipant sends it).
|
|
1018
|
+
func room(_ room: Room, participant: Participant, didUpdatePermissions permissions: ParticipantPermissions) {
|
|
1019
|
+
if participant is LocalParticipant { send(room, .permissions) }
|
|
1020
|
+
}
|
|
858
1021
|
}
|
|
@@ -38,6 +38,16 @@ final class MessageNotifications: NSObject, NotificationDelegate {
|
|
|
38
38
|
static let category = "poolse_message"
|
|
39
39
|
static let replyAction = "reply"
|
|
40
40
|
static let markReadAction = "mark_read"
|
|
41
|
+
/// Scheduled-meeting notices (server docs/MEETINGS.md §11.3): an alert push
|
|
42
|
+
/// with this category; "starting" offers Join.
|
|
43
|
+
static let meetingCategory = "poolse_meeting"
|
|
44
|
+
static let meetingJoinAction = "poolse_meeting_join"
|
|
45
|
+
|
|
46
|
+
/// The bridge's subscriber for meeting taps / Join (`onCallAction`); main thread.
|
|
47
|
+
static var callActionListener: (([String: Any]) -> Void)?
|
|
48
|
+
/// The last one nobody was listening for — the cold start that a Join
|
|
49
|
+
/// launched; `takeCallAction` reads it once. Main thread.
|
|
50
|
+
static var pendingCallAction: [String: Any]?
|
|
41
51
|
|
|
42
52
|
/// The bridge's subscriber for finished notification actions; main thread.
|
|
43
53
|
static var actionListener: (([String: Any]) -> Void)?
|
|
@@ -79,10 +89,23 @@ final class MessageNotifications: NSObject, NotificationDelegate {
|
|
|
79
89
|
categorySummaryFormat: "%u more messages from %@",
|
|
80
90
|
options: []
|
|
81
91
|
)
|
|
92
|
+
// Join opens the app: joining needs the user's session, which only it has.
|
|
93
|
+
let join = UNNotificationAction(identifier: Self.meetingJoinAction, title: "Join", options: [.foreground])
|
|
94
|
+
let meeting = UNNotificationCategory(
|
|
95
|
+
identifier: Self.meetingCategory,
|
|
96
|
+
actions: [join],
|
|
97
|
+
intentIdentifiers: [],
|
|
98
|
+
options: []
|
|
99
|
+
)
|
|
100
|
+
// An agent's question (AGENTS_IN_CALLS.md §5): Approve / Decline / Answer.
|
|
101
|
+
let escalation = EscalationNotifications.makeCategory(requireUnlock: requireUnlock)
|
|
102
|
+
let ours: Set<String> = [Self.category, Self.meetingCategory, EscalationNotifications.category]
|
|
82
103
|
let center = UNUserNotificationCenter.current()
|
|
83
104
|
center.getNotificationCategories { existing in
|
|
84
|
-
var all = existing.filter { $0.identifier
|
|
105
|
+
var all = existing.filter { !ours.contains($0.identifier) }
|
|
85
106
|
all.insert(category)
|
|
107
|
+
all.insert(meeting)
|
|
108
|
+
all.insert(escalation)
|
|
86
109
|
center.setNotificationCategories(all)
|
|
87
110
|
}
|
|
88
111
|
}
|
|
@@ -91,6 +114,10 @@ final class MessageNotifications: NSObject, NotificationDelegate {
|
|
|
91
114
|
|
|
92
115
|
func didReceive(_ response: UNNotificationResponse, completionHandler: @escaping () -> Void) -> Bool {
|
|
93
116
|
let content = response.notification.request.content
|
|
117
|
+
if content.categoryIdentifier == Self.meetingCategory { return meetingResponse(response) }
|
|
118
|
+
if content.categoryIdentifier == EscalationNotifications.category {
|
|
119
|
+
return EscalationNotifications.didReceive(response)
|
|
120
|
+
}
|
|
94
121
|
guard content.categoryIdentifier == Self.category else { return false }
|
|
95
122
|
let action = response.actionIdentifier
|
|
96
123
|
guard action == Self.replyAction || action == Self.markReadAction else {
|
|
@@ -175,6 +202,38 @@ final class MessageNotifications: NSObject, NotificationDelegate {
|
|
|
175
202
|
return true
|
|
176
203
|
}
|
|
177
204
|
|
|
205
|
+
/// A meeting notice's tap (`open`) or Join (`join_meeting`), handed to JS
|
|
206
|
+
/// as a CallAction — the shape Android's notification produces.
|
|
207
|
+
private func meetingResponse(_ response: UNNotificationResponse) -> Bool {
|
|
208
|
+
let content = response.notification.request.content
|
|
209
|
+
let info = content.userInfo
|
|
210
|
+
func str(_ key: String) -> String? { (info[key] as? String).flatMap(nilIfEmpty) }
|
|
211
|
+
let action: String
|
|
212
|
+
switch response.actionIdentifier {
|
|
213
|
+
case Self.meetingJoinAction: action = "join_meeting"
|
|
214
|
+
case UNNotificationDefaultActionIdentifier: action = "open"
|
|
215
|
+
default: return true // dismissed
|
|
216
|
+
}
|
|
217
|
+
guard let conversationId = str("conversation_id") else { return true }
|
|
218
|
+
let server = ServerRegistry.shared.servers.resolve(tenantId: str("tenant_id"))
|
|
219
|
+
let event: [String: Any] = [
|
|
220
|
+
"type": action,
|
|
221
|
+
"conversationId": conversationId,
|
|
222
|
+
"callId": str("call_id") ?? NSNull(),
|
|
223
|
+
"media": str("media") == "video" ? "video" : "audio",
|
|
224
|
+
"serverId": server?.id ?? NSNull(),
|
|
225
|
+
"scheduledMeetingId": str("scheduled_meeting_id") ?? NSNull(),
|
|
226
|
+
]
|
|
227
|
+
DispatchQueue.main.async {
|
|
228
|
+
if let listener = Self.callActionListener {
|
|
229
|
+
listener(event)
|
|
230
|
+
} else {
|
|
231
|
+
Self.pendingCallAction = event
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return true
|
|
235
|
+
}
|
|
236
|
+
|
|
178
237
|
/// A background push: the conversation was read on another device.
|
|
179
238
|
func didReceive(_ userInfo: [AnyHashable: Any],
|
|
180
239
|
completionHandler: @escaping (UIBackgroundFetchResult) -> Void) -> Bool {
|
|
@@ -143,7 +143,12 @@ struct VoipPayload {
|
|
|
143
143
|
var callId: String? { string("call_id") }
|
|
144
144
|
var event: String? { string("event") }
|
|
145
145
|
var reason: String? { string("reason") }
|
|
146
|
-
var title: String? {
|
|
146
|
+
var title: String? {
|
|
147
|
+
if string("ring_type") == "meeting" {
|
|
148
|
+
return "\(string("meeting_title") ?? string("conversation_name") ?? "Meeting") is starting"
|
|
149
|
+
}
|
|
150
|
+
return string("conversation_name") ?? string("caller_name")
|
|
151
|
+
}
|
|
147
152
|
|
|
148
153
|
var media: String {
|
|
149
154
|
if let m = string("media")?.lowercased(), m == "video" || m == "audio" { return m }
|
|
@@ -172,7 +177,11 @@ struct VoipPayload {
|
|
|
172
177
|
// Signed in to several workspaces: the ring is answered (and
|
|
173
178
|
// declined) on the server of its tenant.
|
|
174
179
|
serverId: ServerRegistry.shared.servers.resolve(tenantId: string("tenant_id"))?.id,
|
|
175
|
-
workspaceName: string("workspace_name")
|
|
180
|
+
workspaceName: string("workspace_name"),
|
|
181
|
+
// A scheduled meeting starting (CA4): "Weekly sync is starting".
|
|
182
|
+
ringType: string("ring_type"),
|
|
183
|
+
meetingTitle: string("meeting_title"),
|
|
184
|
+
meetingId: string("meeting_id")
|
|
176
185
|
)
|
|
177
186
|
}
|
|
178
187
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poolse/native",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"description": "Native call core for poolse — Kotlin/Swift calling engine with a thin React Native bridge. Ring, answer and carry audio with the app killed and the phone locked.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|