@stream-io/video-react-native-sdk 1.29.4-beta.0 → 1.30.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 +3162 -0
- package/android/src/main/AndroidManifest.xml +1 -8
- package/android/src/main/AndroidManifestNew.xml +0 -11
- package/android/src/main/java/com/streamvideo/reactnative/StreamVideoReactNativeModule.kt +5 -42
- package/android/src/main/java/com/streamvideo/reactnative/audio/utils/WebRtcAudioUtils.kt +6 -70
- package/android/src/main/java/com/streamvideo/reactnative/callmanager/StreamInCallManagerModule.kt +4 -6
- package/android/src/main/java/com/streamvideo/reactnative/util/CallAliveServiceChecker.kt +95 -0
- package/dist/commonjs/components/Call/CallContent/CallContent.js +13 -7
- package/dist/commonjs/components/Call/CallContent/CallContent.js.map +1 -1
- package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js +50 -14
- package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
- package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js +27 -0
- package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
- package/dist/commonjs/components/Call/CallLayout/CallParticipantsGrid.js +19 -10
- package/dist/commonjs/components/Call/CallLayout/CallParticipantsGrid.js.map +1 -1
- package/dist/commonjs/components/Call/CallLayout/CallParticipantsSpotlight.js +12 -9
- package/dist/commonjs/components/Call/CallLayout/CallParticipantsSpotlight.js.map +1 -1
- package/dist/commonjs/components/Call/CallParticipantsList/CallParticipantsList.js +19 -4
- package/dist/commonjs/components/Call/CallParticipantsList/CallParticipantsList.js.map +1 -1
- package/dist/commonjs/hooks/push/index.js +2 -0
- package/dist/commonjs/hooks/push/index.js.map +1 -1
- package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +160 -0
- package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
- package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/commonjs/hooks/push/useProcessPushCallEffect.js +67 -0
- package/dist/commonjs/hooks/push/useProcessPushCallEffect.js.map +1 -0
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +97 -64
- package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/commonjs/index.js +0 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/modules/call-manager/CallManager.js +0 -26
- package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
- package/dist/commonjs/providers/StreamCall/index.js +6 -6
- package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
- package/dist/commonjs/utils/StreamVideoRN/index.js +21 -33
- package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/commonjs/utils/hooks/index.js +0 -11
- package/dist/commonjs/utils/hooks/index.js.map +1 -1
- package/dist/commonjs/utils/internal/registerSDKGlobals.js +3 -52
- package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/commonjs/utils/push/android.js +202 -151
- package/dist/commonjs/utils/push/android.js.map +1 -1
- package/dist/commonjs/utils/push/internal/ios.js +34 -17
- package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
- package/dist/commonjs/utils/push/internal/rxSubjects.js +45 -1
- package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
- package/dist/commonjs/utils/push/internal/utils.js +20 -32
- package/dist/commonjs/utils/push/internal/utils.js.map +1 -1
- package/dist/commonjs/utils/push/ios.js.map +1 -1
- package/dist/commonjs/utils/push/libs/callkeep.js +17 -0
- package/dist/commonjs/utils/push/libs/callkeep.js.map +1 -0
- package/dist/commonjs/utils/push/libs/index.js +19 -8
- package/dist/commonjs/utils/push/libs/index.js.map +1 -1
- package/dist/commonjs/utils/push/libs/notifee/index.js +19 -0
- package/dist/commonjs/utils/push/libs/notifee/index.js.map +1 -1
- package/dist/commonjs/utils/push/libs/voipPushNotification.js +17 -0
- package/dist/commonjs/utils/push/libs/voipPushNotification.js.map +1 -0
- package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +205 -0
- package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +1 -0
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +6 -7
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/commonjs/version.js.map +1 -1
- package/dist/module/components/Call/CallContent/CallContent.js +10 -4
- package/dist/module/components/Call/CallContent/CallContent.js.map +1 -1
- package/dist/module/components/Call/CallContent/RTCViewPipIOS.js +52 -16
- package/dist/module/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
- package/dist/module/components/Call/CallContent/RTCViewPipNative.js +27 -0
- package/dist/module/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
- package/dist/module/components/Call/CallLayout/CallParticipantsGrid.js +19 -10
- package/dist/module/components/Call/CallLayout/CallParticipantsGrid.js.map +1 -1
- package/dist/module/components/Call/CallLayout/CallParticipantsSpotlight.js +15 -12
- package/dist/module/components/Call/CallLayout/CallParticipantsSpotlight.js.map +1 -1
- package/dist/module/components/Call/CallParticipantsList/CallParticipantsList.js +20 -5
- package/dist/module/components/Call/CallParticipantsList/CallParticipantsList.js.map +1 -1
- package/dist/module/hooks/push/index.js +2 -0
- package/dist/module/hooks/push/index.js.map +1 -1
- package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +153 -0
- package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
- package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
- package/dist/module/hooks/push/useProcessPushCallEffect.js +60 -0
- package/dist/module/hooks/push/useProcessPushCallEffect.js.map +1 -0
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +99 -66
- package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
- package/dist/module/index.js +0 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/modules/call-manager/CallManager.js +0 -26
- package/dist/module/modules/call-manager/CallManager.js.map +1 -1
- package/dist/module/providers/StreamCall/index.js +6 -6
- package/dist/module/providers/StreamCall/index.js.map +1 -1
- package/dist/module/utils/StreamVideoRN/index.js +21 -33
- package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/module/utils/hooks/index.js +0 -1
- package/dist/module/utils/hooks/index.js.map +1 -1
- package/dist/module/utils/internal/registerSDKGlobals.js +3 -52
- package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/module/utils/push/android.js +204 -153
- package/dist/module/utils/push/android.js.map +1 -1
- package/dist/module/utils/push/internal/ios.js +34 -17
- package/dist/module/utils/push/internal/ios.js.map +1 -1
- package/dist/module/utils/push/internal/rxSubjects.js +44 -0
- package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
- package/dist/module/utils/push/internal/utils.js +19 -29
- package/dist/module/utils/push/internal/utils.js.map +1 -1
- package/dist/module/utils/push/ios.js.map +1 -1
- package/dist/module/utils/push/libs/callkeep.js +11 -0
- package/dist/module/utils/push/libs/callkeep.js.map +1 -0
- package/dist/module/utils/push/libs/index.js +2 -1
- package/dist/module/utils/push/libs/index.js.map +1 -1
- package/dist/module/utils/push/libs/notifee/index.js +18 -0
- package/dist/module/utils/push/libs/notifee/index.js.map +1 -1
- package/dist/module/utils/push/libs/voipPushNotification.js +11 -0
- package/dist/module/utils/push/libs/voipPushNotification.js.map +1 -0
- package/dist/module/utils/push/setupIosCallKeepEvents.js +199 -0
- package/dist/module/utils/push/setupIosCallKeepEvents.js.map +1 -0
- package/dist/module/utils/push/setupIosVoipPushEvents.js +6 -7
- package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/module/version.js.map +1 -1
- package/dist/typescript/components/Call/CallContent/CallContent.d.ts.map +1 -1
- package/dist/typescript/components/Call/CallContent/RTCViewPipIOS.d.ts.map +1 -1
- package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts +18 -0
- package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts.map +1 -1
- package/dist/typescript/components/Call/CallLayout/CallParticipantsGrid.d.ts.map +1 -1
- package/dist/typescript/components/Call/CallLayout/CallParticipantsSpotlight.d.ts.map +1 -1
- package/dist/typescript/components/Call/CallParticipantsList/CallParticipantsList.d.ts.map +1 -1
- package/dist/typescript/hooks/push/index.d.ts.map +1 -1
- package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts +5 -0
- package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +1 -0
- package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
- package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts +8 -0
- package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts.map +1 -0
- package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
- package/dist/typescript/index.d.ts +0 -1
- package/dist/typescript/index.d.ts.map +1 -1
- package/dist/typescript/modules/call-manager/CallManager.d.ts +0 -5
- package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/index.d.ts +2 -20
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/types.d.ts +29 -54
- package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
- package/dist/typescript/utils/hooks/index.d.ts +0 -1
- package/dist/typescript/utils/hooks/index.d.ts.map +1 -1
- package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
- package/dist/typescript/utils/push/android.d.ts +2 -1
- package/dist/typescript/utils/push/android.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/ios.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/rxSubjects.d.ts +33 -0
- package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/utils.d.ts +1 -8
- package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
- package/dist/typescript/utils/push/ios.d.ts +2 -1
- package/dist/typescript/utils/push/ios.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/callkeep.d.ts +3 -0
- package/dist/typescript/utils/push/libs/callkeep.d.ts.map +1 -0
- package/dist/typescript/utils/push/libs/index.d.ts +2 -1
- package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/notifee/index.d.ts +1 -0
- package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +3 -0
- package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +1 -0
- package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +6 -0
- package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +1 -0
- package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
- package/dist/typescript/version.d.ts +1 -1
- package/dist/typescript/version.d.ts.map +1 -1
- package/expo-config-plugin/dist/withAndroidManifest.js +33 -1
- package/expo-config-plugin/dist/withAndroidPermissions.js +7 -2
- package/expo-config-plugin/dist/withAppDelegate.js +197 -19
- package/expo-config-plugin/dist/withMainActivity.js +1 -1
- package/expo-config-plugin/dist/withiOSInfoPlist.js +3 -2
- package/ios/PictureInPicture/PictureInPictureAvatarView.swift +273 -0
- package/ios/PictureInPicture/PictureInPictureConnectionQualityIndicator.swift +162 -0
- package/ios/PictureInPicture/PictureInPictureContent.swift +173 -0
- package/ios/PictureInPicture/PictureInPictureContentState.swift +123 -0
- package/ios/PictureInPicture/PictureInPictureDelegateProxy.swift +89 -0
- package/ios/PictureInPicture/PictureInPictureEnforcedStopAdapter.swift +166 -0
- package/ios/PictureInPicture/PictureInPictureLogger.swift +16 -0
- package/ios/PictureInPicture/PictureInPictureParticipantOverlayView.swift +217 -0
- package/ios/PictureInPicture/PictureInPictureReconnectionView.swift +193 -0
- package/ios/PictureInPicture/StreamAVPictureInPictureVideoCallViewController.swift +125 -7
- package/ios/PictureInPicture/StreamPictureInPictureController.swift +237 -63
- package/ios/PictureInPicture/StreamPictureInPictureControllerProtocol.swift +30 -0
- package/ios/PictureInPicture/StreamPictureInPictureVideoRenderer.swift +384 -12
- package/ios/RTCViewPip.swift +187 -21
- package/ios/RTCViewPipManager.mm +9 -0
- package/ios/RTCViewPipManager.swift +3 -3
- package/ios/StreamInCallManager.m +0 -2
- package/ios/StreamInCallManager.swift +7 -19
- package/ios/StreamVideoReactNative.h +4 -7
- package/ios/StreamVideoReactNative.m +82 -189
- package/package.json +19 -14
- package/src/components/Call/CallContent/CallContent.tsx +16 -8
- package/src/components/Call/CallContent/RTCViewPipIOS.tsx +81 -15
- package/src/components/Call/CallContent/RTCViewPipNative.tsx +36 -0
- package/src/components/Call/CallLayout/CallParticipantsGrid.tsx +28 -14
- package/src/components/Call/CallLayout/CallParticipantsSpotlight.tsx +19 -10
- package/src/components/Call/CallParticipantsList/CallParticipantsList.tsx +20 -5
- package/src/hooks/push/index.ts +2 -0
- package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +235 -0
- package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +34 -21
- package/src/hooks/push/useProcessPushCallEffect.ts +108 -0
- package/src/hooks/useAndroidKeepCallAliveEffect.ts +120 -94
- package/src/index.ts +0 -1
- package/src/modules/call-manager/CallManager.ts +0 -36
- package/src/modules/call-manager/native-module.d.ts +0 -7
- package/src/providers/StreamCall/index.tsx +6 -6
- package/src/utils/StreamVideoRN/index.ts +30 -40
- package/src/utils/StreamVideoRN/types.ts +29 -56
- package/src/utils/hooks/index.ts +0 -1
- package/src/utils/internal/registerSDKGlobals.ts +4 -47
- package/src/utils/push/android.ts +309 -227
- package/src/utils/push/internal/ios.ts +44 -28
- package/src/utils/push/internal/rxSubjects.ts +61 -0
- package/src/utils/push/internal/utils.ts +26 -45
- package/src/utils/push/ios.ts +6 -1
- package/src/utils/push/libs/callkeep.ts +16 -0
- package/src/utils/push/libs/index.ts +2 -1
- package/src/utils/push/libs/notifee/index.ts +27 -0
- package/src/utils/push/libs/voipPushNotification.ts +17 -0
- package/src/utils/push/setupIosCallKeepEvents.ts +252 -0
- package/src/utils/push/setupIosVoipPushEvents.ts +7 -11
- package/src/version.ts +1 -1
- package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +0 -83
- package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +0 -149
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +0 -121
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
- package/dist/commonjs/utils/hooks/useDebouncedValue.js +0 -24
- package/dist/commonjs/utils/hooks/useDebouncedValue.js.map +0 -1
- package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js +0 -58
- package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js.map +0 -1
- package/dist/commonjs/utils/internal/callingx/callingx.js +0 -109
- package/dist/commonjs/utils/internal/callingx/callingx.js.map +0 -1
- package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +0 -48
- package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +0 -1
- package/dist/commonjs/utils/push/libs/callingx.js +0 -75
- package/dist/commonjs/utils/push/libs/callingx.js.map +0 -1
- package/dist/commonjs/utils/push/setupCallingExpEvents.js +0 -108
- package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +0 -1
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +0 -114
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
- package/dist/module/utils/hooks/useDebouncedValue.js +0 -19
- package/dist/module/utils/hooks/useDebouncedValue.js.map +0 -1
- package/dist/module/utils/internal/callingx/audioSessionPromise.js +0 -51
- package/dist/module/utils/internal/callingx/audioSessionPromise.js.map +0 -1
- package/dist/module/utils/internal/callingx/callingx.js +0 -100
- package/dist/module/utils/internal/callingx/callingx.js.map +0 -1
- package/dist/module/utils/keepCallAliveHeadlessTask.js +0 -42
- package/dist/module/utils/keepCallAliveHeadlessTask.js.map +0 -1
- package/dist/module/utils/push/libs/callingx.js +0 -67
- package/dist/module/utils/push/libs/callingx.js.map +0 -1
- package/dist/module/utils/push/setupCallingExpEvents.js +0 -102
- package/dist/module/utils/push/setupCallingExpEvents.js.map +0 -1
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +0 -5
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +0 -1
- package/dist/typescript/utils/hooks/useDebouncedValue.d.ts +0 -8
- package/dist/typescript/utils/hooks/useDebouncedValue.d.ts.map +0 -1
- package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts +0 -16
- package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts.map +0 -1
- package/dist/typescript/utils/internal/callingx/callingx.d.ts +0 -14
- package/dist/typescript/utils/internal/callingx/callingx.d.ts.map +0 -1
- package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +0 -10
- package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +0 -1
- package/dist/typescript/utils/push/libs/callingx.d.ts +0 -9
- package/dist/typescript/utils/push/libs/callingx.d.ts.map +0 -1
- package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +0 -8
- package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +0 -1
- package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +0 -147
- package/src/utils/hooks/useDebouncedValue.ts +0 -21
- package/src/utils/internal/callingx/audioSessionPromise.ts +0 -53
- package/src/utils/internal/callingx/callingx.ts +0 -146
- package/src/utils/keepCallAliveHeadlessTask.ts +0 -54
- package/src/utils/push/libs/callingx.ts +0 -90
- package/src/utils/push/setupCallingExpEvents.ts +0 -130
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useIosVoipPushEventsSetupEffect","useInitAndroidTokenAndRest","useIosInitRemoteNotifications","useProcessPushNonRingingCallEffect","usePushRegisterEffect"],"sourceRoot":"../../../../src","sources":["hooks/push/index.ts"],"mappings":"AAAA,SAASA,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,6BAA6B,QAAQ,iCAAiC;AAC/E,SAASC,kCAAkC,QAAQ,sCAAsC;;AAEzF;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACzCF,6BAA6B,CAAC,CAAC;EAC/
|
|
1
|
+
{"version":3,"names":["useIosVoipPushEventsSetupEffect","useProcessPushCallEffect","useInitAndroidTokenAndRest","useIosInitRemoteNotifications","useProcessPushNonRingingCallEffect","usePushRegisterEffect"],"sourceRoot":"../../../../src","sources":["hooks/push/index.ts"],"mappings":"AAAA,SAASA,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,6BAA6B,QAAQ,iCAAiC;AAC/E,SAASC,kCAAkC,QAAQ,sCAAsC;;AAEzF;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACzCF,6BAA6B,CAAC,CAAC;EAC/BH,+BAA+B,CAAC,CAAC;EACjCI,kCAAkC,CAAC,CAAC;EACpCH,wBAAwB,CAAC,CAAC;EAC1BC,0BAA0B,CAAC,CAAC;AAC9B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { CallingState, RxUtils, videoLoggerSystem } from '@stream-io/video-client';
|
|
2
|
+
import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
3
|
+
import { NativeModules, Platform } from 'react-native';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import { StreamVideoRN } from '../../utils';
|
|
6
|
+
import { getCallKeepLib } from '../../utils/push/libs';
|
|
7
|
+
import { voipCallkeepAcceptedCallOnNativeDialerMap$, voipCallkeepCallOnForegroundMap$, voipPushNotificationCallCId$ } from '../../utils/push/internal/rxSubjects';
|
|
8
|
+
const isNonActiveCallingState = callingState => {
|
|
9
|
+
return callingState === CallingState.IDLE || callingState === CallingState.UNKNOWN || callingState === CallingState.LEFT;
|
|
10
|
+
};
|
|
11
|
+
const isAcceptedCallingState = callingState => {
|
|
12
|
+
return callingState === CallingState.JOINING || callingState === CallingState.JOINED;
|
|
13
|
+
};
|
|
14
|
+
const unsubscribeCallkeepEvents = async activeCallCid => {
|
|
15
|
+
const voipPushNotificationCallCId = RxUtils.getCurrentValue(voipPushNotificationCallCId$);
|
|
16
|
+
if (activeCallCid && activeCallCid === voipPushNotificationCallCId) {
|
|
17
|
+
// callkeep events should not be listened anymore so clear the call cid
|
|
18
|
+
voipPushNotificationCallCId$.next(undefined);
|
|
19
|
+
}
|
|
20
|
+
return await NativeModules.StreamVideoReactNative?.removeIncomingCall(activeCallCid);
|
|
21
|
+
};
|
|
22
|
+
const logger = videoLoggerSystem.getLogger('useIosCallkeepWithCallingStateEffect');
|
|
23
|
+
const log = message => {
|
|
24
|
+
logger.warn(message);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* This hook is used to inform the callkeep library that the call has been joined or ended.
|
|
29
|
+
*/
|
|
30
|
+
export const useIosCallkeepWithCallingStateEffect = () => {
|
|
31
|
+
const activeCall = useCall();
|
|
32
|
+
const {
|
|
33
|
+
useCallCallingState
|
|
34
|
+
} = useCallStateHooks();
|
|
35
|
+
const callingState = useCallCallingState();
|
|
36
|
+
const [acceptedForegroundCallkeepMap, setAcceptedForegroundCallkeepMap] = useState();
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
return () => {
|
|
39
|
+
const pushConfig = StreamVideoRN.getConfig().push;
|
|
40
|
+
if (Platform.OS !== 'ios' || !pushConfig || !pushConfig.ios?.pushProviderName) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!pushConfig.android.incomingCallChannel) {
|
|
44
|
+
// TODO: remove this check and find a better way once we have telecom integration for android
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const callkeep = getCallKeepLib();
|
|
48
|
+
// if the component is unmounted and the callID was not reported to callkeep, then report it now
|
|
49
|
+
if (acceptedForegroundCallkeepMap) {
|
|
50
|
+
log(`Ending call in callkeep: ${acceptedForegroundCallkeepMap.cid}, reason: component unmounted and call was present in acceptedForegroundCallkeepMap`);
|
|
51
|
+
unsubscribeCallkeepEvents(acceptedForegroundCallkeepMap.cid).then(() => callkeep.endCall(acceptedForegroundCallkeepMap.uuid));
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, [acceptedForegroundCallkeepMap]);
|
|
55
|
+
const activeCallCid = activeCall?.cid;
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
return () => {
|
|
58
|
+
const pushConfig = StreamVideoRN.getConfig().push;
|
|
59
|
+
if (Platform.OS !== 'ios' || !pushConfig || !pushConfig.ios?.pushProviderName || !activeCallCid) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!pushConfig.android.incomingCallChannel) {
|
|
63
|
+
// TODO: remove this check and find a better way once we have telecom integration for android
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const nativeDialerAcceptedCallMap = RxUtils.getCurrentValue(voipCallkeepAcceptedCallOnNativeDialerMap$);
|
|
67
|
+
const foregroundIncomingCallkeepMap = RxUtils.getCurrentValue(voipCallkeepCallOnForegroundMap$);
|
|
68
|
+
const callkeep = getCallKeepLib();
|
|
69
|
+
if (activeCallCid === nativeDialerAcceptedCallMap?.cid) {
|
|
70
|
+
log(`Ending call in callkeep: ${activeCallCid}, reason: activeCallCid changed or was removed and call was present in nativeDialerAcceptedCallMap`);
|
|
71
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(nativeDialerAcceptedCallMap.uuid));
|
|
72
|
+
// no need to keep this reference anymore
|
|
73
|
+
voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
|
|
74
|
+
} else if (activeCallCid === foregroundIncomingCallkeepMap?.cid) {
|
|
75
|
+
log(`Ending call in callkeep: ${activeCallCid}, reason: activeCallCid changed or was removed and call was present in foregroundIncomingCallkeepMap`);
|
|
76
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(foregroundIncomingCallkeepMap.uuid));
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}, [activeCallCid]);
|
|
80
|
+
const pushConfig = StreamVideoRN.getConfig().push;
|
|
81
|
+
if (Platform.OS !== 'ios' || !pushConfig || !pushConfig.ios.pushProviderName || !activeCallCid) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (!pushConfig.android.incomingCallChannel) {
|
|
85
|
+
// TODO: remove this check and find a better way once we have telecom integration for android
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Check if current call is still needed to be accepted in callkeep
|
|
91
|
+
*/
|
|
92
|
+
if (isAcceptedCallingState(callingState) && acceptedForegroundCallkeepMap?.cid !== activeCallCid) {
|
|
93
|
+
const callkeep = getCallKeepLib();
|
|
94
|
+
// push notification was displayed
|
|
95
|
+
// but the call has been accepted through the app and not through the native dialer
|
|
96
|
+
const foregroundCallkeepMap = RxUtils.getCurrentValue(voipCallkeepCallOnForegroundMap$);
|
|
97
|
+
if (foregroundCallkeepMap && foregroundCallkeepMap.cid === activeCallCid) {
|
|
98
|
+
log(
|
|
99
|
+
// @ts-expect-error - types issue
|
|
100
|
+
`Accepting call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in foregroundCallkeepMap`);
|
|
101
|
+
// no need to keep this reference anymore
|
|
102
|
+
voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
103
|
+
NativeModules.StreamVideoReactNative?.removeIncomingCall(activeCallCid).then(() => callkeep.answerIncomingCall(foregroundCallkeepMap.uuid));
|
|
104
|
+
// this call should be accepted in callkeep
|
|
105
|
+
setAcceptedForegroundCallkeepMap(foregroundCallkeepMap);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Check if current call is still needed to be ended in callkeep
|
|
111
|
+
*/
|
|
112
|
+
if (isNonActiveCallingState(callingState)) {
|
|
113
|
+
const callkeep = getCallKeepLib();
|
|
114
|
+
|
|
115
|
+
// this was a previously joined call which had push notification displayed
|
|
116
|
+
// the call was accepted through the app and not through native dialer
|
|
117
|
+
// the call was left using the leave button in the app and not through native dialer
|
|
118
|
+
if (activeCallCid === acceptedForegroundCallkeepMap?.cid) {
|
|
119
|
+
log(
|
|
120
|
+
// @ts-expect-error - types issue
|
|
121
|
+
`Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in acceptedForegroundCallkeepMap`);
|
|
122
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(acceptedForegroundCallkeepMap.uuid));
|
|
123
|
+
setAcceptedForegroundCallkeepMap(undefined);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
// this was a call which had push notification displayed but never joined
|
|
127
|
+
// the user rejected in the app and not from native dialer
|
|
128
|
+
const foregroundIncomingCallkeepMap = RxUtils.getCurrentValue(voipCallkeepCallOnForegroundMap$);
|
|
129
|
+
if (activeCallCid === foregroundIncomingCallkeepMap?.cid) {
|
|
130
|
+
log(
|
|
131
|
+
// @ts-expect-error - types issue
|
|
132
|
+
`Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in foregroundIncomingCallkeepMap`);
|
|
133
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(foregroundIncomingCallkeepMap.uuid));
|
|
134
|
+
// no need to keep this reference anymore
|
|
135
|
+
voipCallkeepCallOnForegroundMap$.next(undefined);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
// this was a previously joined call
|
|
139
|
+
// it was an accepted call from native dialer and not from the app
|
|
140
|
+
// the user left using the leave button in the app
|
|
141
|
+
const nativeDialerAcceptedCallMap = RxUtils.getCurrentValue(voipCallkeepAcceptedCallOnNativeDialerMap$);
|
|
142
|
+
if (activeCallCid === nativeDialerAcceptedCallMap?.cid) {
|
|
143
|
+
log(
|
|
144
|
+
// @ts-expect-error - types issue
|
|
145
|
+
`Ending call in callkeep: ${activeCallCid}, reason: callingstate went to ${CallingState[callingState]} and call was present in nativeDialerAcceptedCallMap`);
|
|
146
|
+
unsubscribeCallkeepEvents(activeCallCid).then(() => callkeep.endCall(nativeDialerAcceptedCallMap.uuid));
|
|
147
|
+
// no need to keep this reference anymore
|
|
148
|
+
voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
//# sourceMappingURL=useIosCallkeepWithCallingStateEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CallingState","RxUtils","videoLoggerSystem","useCall","useCallStateHooks","NativeModules","Platform","useEffect","useState","StreamVideoRN","getCallKeepLib","voipCallkeepAcceptedCallOnNativeDialerMap$","voipCallkeepCallOnForegroundMap$","voipPushNotificationCallCId$","isNonActiveCallingState","callingState","IDLE","UNKNOWN","LEFT","isAcceptedCallingState","JOINING","JOINED","unsubscribeCallkeepEvents","activeCallCid","voipPushNotificationCallCId","getCurrentValue","next","undefined","StreamVideoReactNative","removeIncomingCall","logger","getLogger","log","message","warn","useIosCallkeepWithCallingStateEffect","activeCall","useCallCallingState","acceptedForegroundCallkeepMap","setAcceptedForegroundCallkeepMap","pushConfig","getConfig","push","OS","ios","pushProviderName","android","incomingCallChannel","callkeep","cid","then","endCall","uuid","nativeDialerAcceptedCallMap","foregroundIncomingCallkeepMap","foregroundCallkeepMap","answerIncomingCall"],"sourceRoot":"../../../../src","sources":["hooks/push/useIosCallkeepWithCallingStateEffect.ts"],"mappings":"AAAA,SACEA,YAAY,EACZC,OAAO,EACPC,iBAAiB,QACZ,yBAAyB;AAChC,SAASC,OAAO,EAAEC,iBAAiB,QAAQ,iCAAiC;AAC5E,SAASC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SACEC,0CAA0C,EAC1CC,gCAAgC,EAChCC,4BAA4B,QACvB,sCAAsC;AAE7C,MAAMC,uBAAuB,GAAIC,YAA0B,IAAK;EAC9D,OACEA,YAAY,KAAKf,YAAY,CAACgB,IAAI,IAClCD,YAAY,KAAKf,YAAY,CAACiB,OAAO,IACrCF,YAAY,KAAKf,YAAY,CAACkB,IAAI;AAEtC,CAAC;AAED,MAAMC,sBAAsB,GAAIJ,YAA0B,IAAK;EAC7D,OACEA,YAAY,KAAKf,YAAY,CAACoB,OAAO,IACrCL,YAAY,KAAKf,YAAY,CAACqB,MAAM;AAExC,CAAC;AAED,MAAMC,yBAAyB,GAAG,MAAOC,aAAiC,IAAK;EAC7E,MAAMC,2BAA2B,GAAGvB,OAAO,CAACwB,eAAe,CACzDZ,4BACF,CAAC;EACD,IAAIU,aAAa,IAAIA,aAAa,KAAKC,2BAA2B,EAAE;IAClE;IACAX,4BAA4B,CAACa,IAAI,CAACC,SAAS,CAAC;EAC9C;EACA,OAAO,MAAMtB,aAAa,CAACuB,sBAAsB,EAAEC,kBAAkB,CACnEN,aACF,CAAC;AACH,CAAC;AAED,MAAMO,MAAM,GAAG5B,iBAAiB,CAAC6B,SAAS,CACxC,sCACF,CAAC;AACD,MAAMC,GAAG,GAAIC,OAAe,IAAK;EAC/BH,MAAM,CAACI,IAAI,CAACD,OAAO,CAAC;AACtB,CAAC;;AAED;AACA;AACA;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,MAC5CF,QAAQ,CAACG,OAAO,CAACG,6BAA6B,CAACF,IAAI,CACrD,CAAC;MACD;MACAxC,gCAAgC,CAACc,IAAI,CAACC,SAAS,CAAC;MAChD;IACF;IACA;IACA;IACA;IACA,MAAM0B,2BAA2B,GAAGpD,OAAO,CAACwB,eAAe,CACzDd,0CACF,CAAC;IACD,IAAIY,aAAa,KAAK8B,2BAA2B,EAAEJ,GAAG,EAAE;MACtDjB,GAAG;MACD;MACA,4BAA4BT,aAAa,kCAAkCvB,YAAY,CAACe,YAAY,CAAC,sDACvG,CAAC;MACDO,yBAAyB,CAACC,aAAa,CAAC,CAAC2B,IAAI,CAAC,MAC5CF,QAAQ,CAACG,OAAO,CAACE,2BAA2B,CAACD,IAAI,CACnD,CAAC;MACD;MACAzC,0CAA0C,CAACe,IAAI,CAACC,SAAS,CAAC;MAC1D;IACF;EACF;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { getVoipPushNotificationLib } from '../../utils/push/libs';
|
|
2
3
|
import { Platform } from 'react-native';
|
|
3
4
|
import { StreamVideoRN } from '../../utils';
|
|
4
5
|
import { onVoipNotificationReceived } from '../../utils/push/internal/ios';
|
|
5
6
|
import { useConnectedUser, useStreamVideoClient } from '@stream-io/video-react-bindings';
|
|
6
7
|
import { setPushLogoutCallback } from '../../utils/internal/pushLogoutCallback';
|
|
7
8
|
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
8
|
-
import { getCallingxLibIfAvailable } from '../../utils/push/libs';
|
|
9
9
|
const logger = videoLoggerSystem.getLogger('useIosVoipPushEventsSetupEffect');
|
|
10
10
|
|
|
11
11
|
/* VoipPushNotificationLib has support for only one listener type at a time
|
|
@@ -23,7 +23,6 @@ function setLogoutCallback(client, token, lastVoipTokenRef) {
|
|
|
23
23
|
};
|
|
24
24
|
try {
|
|
25
25
|
await client.removeDevice(token);
|
|
26
|
-
logger.debug('PushLogoutCallback - Removed voip token', token);
|
|
27
26
|
} catch (err) {
|
|
28
27
|
logger.warn('PushLogoutCallback - Failed to remove voip token', err);
|
|
29
28
|
}
|
|
@@ -78,10 +77,20 @@ export const useIosVoipPushEventsSetupEffect = () => {
|
|
|
78
77
|
useEffect(() => {
|
|
79
78
|
const pushConfig = StreamVideoRN.getConfig().push;
|
|
80
79
|
const pushProviderName = pushConfig?.ios.pushProviderName;
|
|
81
|
-
|
|
82
|
-
if (Platform.OS !== 'ios' || !client || !pushProviderName || !callingx) {
|
|
80
|
+
if (Platform.OS !== 'ios' || !client || !pushProviderName) {
|
|
83
81
|
return;
|
|
84
82
|
}
|
|
83
|
+
if (!pushConfig.android.incomingCallChannel) {
|
|
84
|
+
// TODO: remove this check and find a better way once we have telecom integration for android
|
|
85
|
+
logger.debug('android incomingCallChannel is not defined, so skipping the useIosVoipPushEventsSetupEffect');
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const voipPushNotification = getVoipPushNotificationLib();
|
|
89
|
+
|
|
90
|
+
// even though we do this natively, we have to still register here again
|
|
91
|
+
// natively this will make sure "register" event for JS is sent with the last push token
|
|
92
|
+
// Necessary if client changed before we got the event here or user logged out and logged in again
|
|
93
|
+
voipPushNotification.registerVoipToken();
|
|
85
94
|
const onTokenReceived = token => {
|
|
86
95
|
const userId = client.streamClient._user?.id ?? '';
|
|
87
96
|
if (client.streamClient.anonymous || !token || !userId) {
|
|
@@ -109,24 +118,27 @@ export const useIosVoipPushEventsSetupEffect = () => {
|
|
|
109
118
|
});
|
|
110
119
|
};
|
|
111
120
|
// fired when PushKit give us the latest token
|
|
112
|
-
|
|
113
|
-
token
|
|
114
|
-
}) => {
|
|
121
|
+
voipPushNotification.addEventListener('register', token => {
|
|
115
122
|
onTokenReceived(token);
|
|
116
123
|
});
|
|
117
124
|
|
|
118
|
-
// this will
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
// this will fire when there are events occured before js bridge initialized
|
|
126
|
+
voipPushNotification.addEventListener('didLoadWithEvents', events => {
|
|
127
|
+
if (!events || !Array.isArray(events) || events.length < 1) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
for (const voipPushEvent of events) {
|
|
131
|
+
const {
|
|
132
|
+
name,
|
|
133
|
+
data
|
|
134
|
+
} = voipPushEvent;
|
|
135
|
+
if (name === 'RNVoipPushRemoteNotificationsRegisteredEvent') {
|
|
136
|
+
onTokenReceived(data);
|
|
137
|
+
} else if (name === 'RNVoipPushRemoteNotificationReceivedEvent') {
|
|
138
|
+
onVoipNotificationReceived(data, pushConfig);
|
|
139
|
+
}
|
|
127
140
|
}
|
|
128
141
|
});
|
|
129
|
-
callingx.registerVoipToken();
|
|
130
142
|
lastListener.count += 1;
|
|
131
143
|
const currentListenerCount = lastListener.count;
|
|
132
144
|
return () => {
|
|
@@ -136,7 +148,8 @@ export const useIosVoipPushEventsSetupEffect = () => {
|
|
|
136
148
|
return;
|
|
137
149
|
}
|
|
138
150
|
logger.debug(`Voip event listeners are removed for user: ${userId}`);
|
|
139
|
-
|
|
151
|
+
voipPushNotification.removeEventListener('didLoadWithEvents');
|
|
152
|
+
voipPushNotification.removeEventListener('register');
|
|
140
153
|
};
|
|
141
154
|
}, [client]);
|
|
142
155
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","useState","Platform","StreamVideoRN","onVoipNotificationReceived","useConnectedUser","useStreamVideoClient","setPushLogoutCallback","videoLoggerSystem","
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","getVoipPushNotificationLib","Platform","StreamVideoRN","onVoipNotificationReceived","useConnectedUser","useStreamVideoClient","setPushLogoutCallback","videoLoggerSystem","logger","getLogger","lastListener","count","setLogoutCallback","client","token","lastVoipTokenRef","current","userId","removeDevice","err","warn","useIosVoipPushEventsSetupEffect","connectedUserId","id","unsentToken","setUnsentToken","pushProviderName","getConfig","push","ios","tokenToSend","debug","addVoipDevice","then","undefined","catch","error","pushConfig","OS","android","incomingCallChannel","voipPushNotification","registerVoipToken","onTokenReceived","streamClient","_user","anonymous","reason","lastVoipToken","addEventListener","events","Array","isArray","length","voipPushEvent","name","data","currentListenerCount","removeEventListener"],"sourceRoot":"../../../../src","sources":["hooks/push/useIosVoipPushEventsSetupEffect.ts"],"mappings":"AAAA,SAAgCA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC1E,SAASC,0BAA0B,QAAQ,uBAAuB;AAElE,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,0BAA0B,QAAQ,+BAA+B;AAC1E,SACEC,gBAAgB,EAChBC,oBAAoB,QACf,iCAAiC;AACxC,SAASC,qBAAqB,QAAQ,yCAAyC;AAC/E,SAA4BC,iBAAiB,QAAQ,yBAAyB;AAE9E,MAAMC,MAAM,GAAGD,iBAAiB,CAACE,SAAS,CAAC,iCAAiC,CAAC;;AAE7E;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAG;EAAEC,KAAK,EAAE;AAAE,CAAC;AAEjC,SAASC,iBAAiBA,CACxBC,MAAyB,EACzBC,KAAa,EACbC,gBAAqE,EACrE;EACAT,qBAAqB,CAAC,YAAY;IAChCS,gBAAgB,CAACC,OAAO,GAAG;MAAEF,KAAK,EAAE,EAAE;MAAEG,MAAM,EAAE;IAAG,CAAC;IACpD,IAAI;MACF,MAAMJ,MAAM,CAACK,YAAY,CAACJ,KAAK,CAAC;IAClC,CAAC,CAAC,OAAOK,GAAG,EAAE;MACZX,MAAM,CAACY,IAAI,CAAC,kDAAkD,EAAED,GAAG,CAAC;IACtE;EACF,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAME,+BAA+B,GAAGA,CAAA,KAAM;EACnD,MAAMR,MAAM,GAAGR,oBAAoB,CAAC,CAAC;EACrC,MAA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,CAAC;IACvB,MAAM8C,oBAAoB,GAAG/C,YAAY,CAACC,KAAK;IAE/C,OAAO,MAAM;MACX,MAAMM,MAAM,GAAGJ,MAAM,CAAC+B,YAAY,CAACC,KAAK,EAAEtB,EAAE;MAC5C,IAAIkC,oBAAoB,KAAK/C,YAAY,CAACC,KAAK,EAAE;QAC/CH,MAAM,CAACuB,KAAK,CACV,mDAAmDd,MAAM,EAC3D,CAAC;QACD;MACF;MACAT,MAAM,CAACuB,KAAK,CAAC,8CAA8Cd,MAAM,EAAE,CAAC;MACpEwB,oBAAoB,CAACiB,mBAAmB,CAAC,mBAAmB,CAAC;MAC7DjB,oBAAoB,CAACiB,mBAAmB,CAAC,UAAU,CAAC;IACtD,CAAC;EACH,CAAC,EAAE,CAAC7C,MAAM,CAAC,CAAC;AACd,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { pushAcceptedIncomingCallCId$, pushAndroidBackgroundDeliveredIncomingCallCId$, pushRejectedIncomingCallCId$, pushTappedIncomingCallCId$ } from '../../utils/push/internal/rxSubjects';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { StreamVideoRN } from '../../utils';
|
|
4
|
+
import { useConnectedUser, useStreamVideoClient } from '@stream-io/video-react-bindings';
|
|
5
|
+
import { distinctUntilChanged, filter } from 'rxjs/operators';
|
|
6
|
+
import { processCallFromPush } from '../../utils/push/internal/utils';
|
|
7
|
+
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
8
|
+
/**
|
|
9
|
+
* This hook is used to process the incoming call data via push notifications using the relevant rxjs subjects
|
|
10
|
+
* It either joins or leaves the call based on the user's action.
|
|
11
|
+
* Note: this effect cannot work when push notifications are received when the app is in quit state or in other words when the client is not connected with a websocket.
|
|
12
|
+
* So we essentially run this effect only when the client is connected with a websocket.
|
|
13
|
+
*/
|
|
14
|
+
export const useProcessPushCallEffect = () => {
|
|
15
|
+
const client = useStreamVideoClient();
|
|
16
|
+
const connectedUserId = useConnectedUser()?.id;
|
|
17
|
+
// The Effect to join/reject call automatically when incoming call was received and processed from push notification
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const pushConfig = StreamVideoRN.getConfig().push;
|
|
20
|
+
if (!pushConfig || !client || !connectedUserId) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
videoLoggerSystem.getLogger('useProcessPushCallEffect').debug(`Adding subscriptions to process incoming call from push notification`);
|
|
24
|
+
|
|
25
|
+
// if the user accepts the call from push notification we join the call
|
|
26
|
+
const acceptedCallSubscription = createCallSubscription(pushAcceptedIncomingCallCId$, client, pushConfig, 'accept');
|
|
27
|
+
|
|
28
|
+
// if the user rejects the call from push notification we leave the call
|
|
29
|
+
const declinedCallSubscription = createCallSubscription(pushRejectedIncomingCallCId$, client, pushConfig, 'decline');
|
|
30
|
+
|
|
31
|
+
// if the user taps the call from push notification we do nothing as the only thing is to get the call which adds it to the client
|
|
32
|
+
const pressedCallSubscription = createCallSubscription(pushTappedIncomingCallCId$, client, pushConfig, 'pressed');
|
|
33
|
+
const backgroundIncomingDeliveredCallSubscription = createCallSubscription(pushAndroidBackgroundDeliveredIncomingCallCId$, client, pushConfig, 'backgroundDelivered');
|
|
34
|
+
return () => {
|
|
35
|
+
acceptedCallSubscription.unsubscribe();
|
|
36
|
+
declinedCallSubscription.unsubscribe();
|
|
37
|
+
pressedCallSubscription.unsubscribe();
|
|
38
|
+
backgroundIncomingDeliveredCallSubscription.unsubscribe();
|
|
39
|
+
};
|
|
40
|
+
}, [client, connectedUserId]);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A type guard to check if the cid is not undefined
|
|
45
|
+
*/
|
|
46
|
+
function cidIsNotUndefined(cid) {
|
|
47
|
+
return cid !== undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The common logic to create a subscription for the given call cid and action
|
|
52
|
+
*/
|
|
53
|
+
const createCallSubscription = (behaviourSubjectWithCallCid, client, pushConfig, action) => {
|
|
54
|
+
return behaviourSubjectWithCallCid.pipe(distinctUntilChanged(), filter(cidIsNotUndefined)).subscribe(async callCId => {
|
|
55
|
+
videoLoggerSystem.getLogger('useProcessPushCallEffect').debug(`Processing call from push notification with action: ${action} and callCId: ${callCId}`);
|
|
56
|
+
await processCallFromPush(client, callCId, action, pushConfig);
|
|
57
|
+
behaviourSubjectWithCallCid.next(undefined); // remove the current call id to avoid processing again
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=useProcessPushCallEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["pushAcceptedIncomingCallCId$","pushAndroidBackgroundDeliveredIncomingCallCId$","pushRejectedIncomingCallCId$","pushTappedIncomingCallCId$","useEffect","StreamVideoRN","useConnectedUser","useStreamVideoClient","distinctUntilChanged","filter","processCallFromPush","videoLoggerSystem","useProcessPushCallEffect","client","connectedUserId","id","pushConfig","getConfig","push","getLogger","debug","acceptedCallSubscription","createCallSubscription","declinedCallSubscription","pressedCallSubscription","backgroundIncomingDeliveredCallSubscription","unsubscribe","cidIsNotUndefined","cid","undefined","behaviourSubjectWithCallCid","action","pipe","subscribe","callCId","next"],"sourceRoot":"../../../../src","sources":["hooks/push/useProcessPushCallEffect.ts"],"mappings":"AAAA,SACEA,4BAA4B,EAC5BC,8CAA8C,EAC9CC,4BAA4B,EAC5BC,0BAA0B,QACrB,sCAAsC;AAC7C,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,aAAa,QAAQ,aAAa;AAC3C,SACEC,gBAAgB,EAChBC,oBAAoB,QACf,iCAAiC;AAExC,SAASC,oBAAoB,EAAEC,MAAM,QAAQ,gBAAgB;AAC7D,SAASC,mBAAmB,QAAQ,iCAAiC;AACrE,SAA4BC,iBAAiB,QAAQ,yBAAyB;AAG9E;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EAC5C,MAA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,2BAA2B,CAC/BE,IAAI,CAACxB,oBAAoB,CAAC,CAAC,EAAEC,MAAM,CAACkB,iBAAiB,CAAC,CAAC,CACvDM,SAAS,CAAC,MAAOC,OAAO,IAAK;IAC5BvB,iBAAiB,CACdQ,SAAS,CAAC,0BAA0B,CAAC,CACrCC,KAAK,CACJ,uDAAuDW,MAAM,iBAAiBG,OAAO,EACvF,CAAC;IACH,MAAMxB,mBAAmB,CAACG,MAAM,EAAEqB,OAAO,EAAEH,MAAM,EAAEf,UAAU,CAAC;IAC9Dc,2BAA2B,CAACK,IAAI,CAACN,SAAS,CAAC,CAAC,CAAC;EAC/C,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1,58 +1,93 @@
|
|
|
1
1
|
import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
3
|
import { StreamVideoRN } from '../utils';
|
|
4
|
-
import { AppState, NativeModules,
|
|
4
|
+
import { AppState, NativeModules, Platform } from 'react-native';
|
|
5
5
|
import { CallingState, videoLoggerSystem } from '@stream-io/video-client';
|
|
6
|
-
import {
|
|
7
|
-
import { getNotifeeLibNoThrowForKeepCallAlive } from '../utils/push/libs/notifee';
|
|
8
|
-
import { getCallingxLibIfAvailable } from '../utils/push/libs';
|
|
6
|
+
import { getKeepCallAliveForegroundServiceTypes, getNotifeeLibNoThrowForKeepCallAlive } from '../utils/push/libs/notifee';
|
|
9
7
|
const notifeeLib = getNotifeeLibNoThrowForKeepCallAlive();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
const callToPassToForegroundService = {
|
|
9
|
+
current: undefined
|
|
10
|
+
};
|
|
11
|
+
function setForegroundService() {
|
|
12
|
+
if (Platform.OS === 'ios' || !notifeeLib) return;
|
|
13
|
+
NativeModules.StreamVideoReactNative.isCallAliveConfigured().then(isConfigured => {
|
|
14
|
+
if (!isConfigured) {
|
|
15
|
+
const logger = videoLoggerSystem.getLogger('setForegroundService method');
|
|
16
|
+
logger.info('KeepCallAlive is not configured. Skipping foreground service setup.');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
notifeeLib.default.registerForegroundService(() => {
|
|
20
|
+
const task = new Promise(resolve => {
|
|
21
|
+
const logger = videoLoggerSystem.getLogger('setForegroundService method');
|
|
22
|
+
logger.info('Foreground service running for call in progress');
|
|
23
|
+
// any task to run from SDK in the foreground service must be added
|
|
24
|
+
resolve(true);
|
|
25
|
+
});
|
|
26
|
+
const videoConfig = StreamVideoRN.getConfig();
|
|
27
|
+
const foregroundServiceConfig = videoConfig.foregroundService;
|
|
28
|
+
const {
|
|
29
|
+
taskToRun
|
|
30
|
+
} = foregroundServiceConfig.android;
|
|
31
|
+
const call = callToPassToForegroundService.current;
|
|
32
|
+
if (!call) {
|
|
33
|
+
const logger = videoLoggerSystem.getLogger('setForegroundService method');
|
|
34
|
+
logger.warn('No call to pass to foreground service');
|
|
35
|
+
return task.then(() => new Promise(() => {}));
|
|
36
|
+
}
|
|
37
|
+
callToPassToForegroundService.current = undefined;
|
|
38
|
+
return task.then(() => taskToRun(call));
|
|
39
|
+
});
|
|
40
|
+
});
|
|
17
41
|
}
|
|
18
42
|
async function startForegroundService(call_cid) {
|
|
19
|
-
const
|
|
20
|
-
const isCallAliveConfigured = await (async () => {
|
|
21
|
-
try {
|
|
22
|
-
return await NativeModules.StreamVideoReactNative.isCallAliveConfigured();
|
|
23
|
-
} catch (e) {
|
|
24
|
-
logger.warn('Failed to check whether KeepCallAlive is configured', e);
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
})();
|
|
43
|
+
const isCallAliveConfigured = await NativeModules.StreamVideoReactNative.isCallAliveConfigured();
|
|
28
44
|
if (!isCallAliveConfigured) {
|
|
45
|
+
const logger = videoLoggerSystem.getLogger('startForegroundService');
|
|
29
46
|
logger.info('KeepCallAlive is not configured. Skipping foreground service setup.');
|
|
30
47
|
return;
|
|
31
48
|
}
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
// check for notification permission and then start the foreground service
|
|
50
|
+
if (!notifeeLib) return;
|
|
51
|
+
const settings = await notifeeLib.default.getNotificationSettings();
|
|
52
|
+
if (settings.authorizationStatus !== notifeeLib.AuthorizationStatus.AUTHORIZED) {
|
|
53
|
+
const logger = videoLoggerSystem.getLogger('startForegroundService');
|
|
35
54
|
logger.info('Notification permission not granted, can not start foreground service to keep the call alive');
|
|
36
55
|
return;
|
|
37
56
|
}
|
|
38
57
|
const videoConfig = StreamVideoRN.getConfig();
|
|
39
58
|
const foregroundServiceConfig = videoConfig.foregroundService;
|
|
40
59
|
const notificationTexts = foregroundServiceConfig.android.notificationTexts;
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
const channelId = foregroundServiceConfig.android.channel.id;
|
|
61
|
+
await notifeeLib.default.createChannel(foregroundServiceConfig.android.channel);
|
|
62
|
+
const foregroundServiceTypes = await getKeepCallAliveForegroundServiceTypes();
|
|
44
63
|
// NOTE: we use requestAnimationFrame to ensure that the foreground service is started after all the current UI operations are done
|
|
45
64
|
// this is a workaround for the crash - android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground()
|
|
46
65
|
// this crash was reproducible only in some android devices
|
|
47
|
-
requestAnimationFrame(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
66
|
+
requestAnimationFrame(() => {
|
|
67
|
+
notifeeLib.default.displayNotification({
|
|
68
|
+
id: call_cid,
|
|
69
|
+
title: notificationTexts.title,
|
|
70
|
+
body: notificationTexts.body,
|
|
71
|
+
android: {
|
|
72
|
+
channelId,
|
|
73
|
+
smallIcon: videoConfig.push?.android.smallIcon,
|
|
74
|
+
foregroundServiceTypes,
|
|
75
|
+
asForegroundService: true,
|
|
76
|
+
ongoing: true,
|
|
77
|
+
// user cannot dismiss the notification
|
|
78
|
+
colorized: true,
|
|
79
|
+
pressAction: {
|
|
80
|
+
id: 'default',
|
|
81
|
+
launchActivity: 'default' // open the app when the notification is pressed
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
53
85
|
});
|
|
54
86
|
}
|
|
55
87
|
|
|
88
|
+
// flag to check if setForegroundService has already been run once
|
|
89
|
+
let isSetForegroundServiceRan = false;
|
|
90
|
+
|
|
56
91
|
/**
|
|
57
92
|
* This hook is used to keep the call alive in the background for Android.
|
|
58
93
|
* It starts a foreground service to keep the call alive as soon as the call is joined
|
|
@@ -62,7 +97,7 @@ async function startForegroundService(call_cid) {
|
|
|
62
97
|
export const useAndroidKeepCallAliveEffect = () => {
|
|
63
98
|
const foregroundServiceStartedRef = useRef(false);
|
|
64
99
|
const call = useCall();
|
|
65
|
-
|
|
100
|
+
callToPassToForegroundService.current = call;
|
|
66
101
|
const activeCallCid = call?.cid;
|
|
67
102
|
const {
|
|
68
103
|
useCallCallingState
|
|
@@ -70,16 +105,12 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
70
105
|
const callingState = useCallCallingState();
|
|
71
106
|
const isOutgoingCall = callingState === CallingState.RINGING && call?.isCreatedByMe;
|
|
72
107
|
const isCallJoined = callingState === CallingState.JOINED;
|
|
73
|
-
const isRingingCall = call?.ringing;
|
|
74
108
|
const shouldStartForegroundService = !foregroundServiceStartedRef.current && (isOutgoingCall || isCallJoined);
|
|
75
109
|
useEffect(() => {
|
|
76
110
|
if (Platform.OS === 'ios' || !activeCallCid) {
|
|
77
111
|
return undefined;
|
|
78
112
|
}
|
|
79
|
-
|
|
80
|
-
if (callingx?.isSetup && (isRingingCall || !isRingingCall && callingx?.isOngoingCallsEnabled)) {
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
113
|
+
if (!notifeeLib) return undefined;
|
|
83
114
|
|
|
84
115
|
// start foreground service as soon as the call is joined
|
|
85
116
|
if (shouldStartForegroundService) {
|
|
@@ -87,18 +118,21 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
87
118
|
if (foregroundServiceStartedRef.current) {
|
|
88
119
|
return;
|
|
89
120
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
121
|
+
if (!isSetForegroundServiceRan) {
|
|
122
|
+
isSetForegroundServiceRan = true;
|
|
123
|
+
setForegroundService();
|
|
124
|
+
}
|
|
125
|
+
const notifee = notifeeLib.default;
|
|
126
|
+
const displayedNotifications = await notifee.getDisplayedNotifications();
|
|
127
|
+
const activeCallNotification = displayedNotifications.find(notification => notification.id === activeCallCid);
|
|
128
|
+
if (activeCallNotification) {
|
|
129
|
+
callToPassToForegroundService.current = undefined;
|
|
130
|
+
// this means that we have a incoming call notification shown as foreground service and we must stop it
|
|
131
|
+
notifee.stopForegroundService();
|
|
132
|
+
notifee.cancelDisplayedNotification(activeCallCid);
|
|
101
133
|
}
|
|
134
|
+
// check for notification permission and then start the foreground service
|
|
135
|
+
|
|
102
136
|
await startForegroundService(activeCallCid);
|
|
103
137
|
foregroundServiceStartedRef.current = true;
|
|
104
138
|
};
|
|
@@ -106,6 +140,7 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
106
140
|
// ensure that app is active before running the function
|
|
107
141
|
if (AppState.currentState === 'active') {
|
|
108
142
|
run();
|
|
143
|
+
return undefined;
|
|
109
144
|
}
|
|
110
145
|
const sub = AppState.addEventListener('change', nextAppState => {
|
|
111
146
|
if (nextAppState === 'active') {
|
|
@@ -120,36 +155,34 @@ export const useAndroidKeepCallAliveEffect = () => {
|
|
|
120
155
|
return () => {
|
|
121
156
|
// cancel any notifee displayed notification when the call has transitioned out of ringing
|
|
122
157
|
// NOTE: cancels only the non fg service notifications
|
|
123
|
-
|
|
124
|
-
notifeeLib.default.cancelDisplayedNotification(activeCallCid);
|
|
125
|
-
}
|
|
158
|
+
notifeeLib.default.cancelDisplayedNotification(activeCallCid);
|
|
126
159
|
};
|
|
127
160
|
} else if (callingState === CallingState.IDLE || callingState === CallingState.LEFT) {
|
|
128
161
|
if (foregroundServiceStartedRef.current) {
|
|
129
|
-
|
|
162
|
+
callToPassToForegroundService.current = undefined;
|
|
130
163
|
// stop foreground service when the call is not active
|
|
131
|
-
|
|
164
|
+
notifeeLib.default.stopForegroundService();
|
|
132
165
|
foregroundServiceStartedRef.current = false;
|
|
133
166
|
} else {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
167
|
+
notifeeLib.default.getDisplayedNotifications().then(displayedNotifications => {
|
|
168
|
+
const activeCallNotification = displayedNotifications.find(notification => notification.id === activeCallCid);
|
|
169
|
+
if (activeCallNotification) {
|
|
170
|
+
callToPassToForegroundService.current = undefined;
|
|
171
|
+
// this means that we have a incoming call notification shown as foreground service and we must stop it
|
|
172
|
+
notifeeLib.default.stopForegroundService();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
143
175
|
}
|
|
144
176
|
}
|
|
145
177
|
return undefined;
|
|
146
|
-
}, [activeCallCid, callingState, shouldStartForegroundService
|
|
178
|
+
}, [activeCallCid, callingState, shouldStartForegroundService]);
|
|
147
179
|
useEffect(() => {
|
|
148
180
|
return () => {
|
|
149
181
|
// stop foreground service when this effect is unmounted
|
|
150
182
|
if (foregroundServiceStartedRef.current) {
|
|
151
|
-
|
|
152
|
-
|
|
183
|
+
if (!notifeeLib) return;
|
|
184
|
+
callToPassToForegroundService.current = undefined;
|
|
185
|
+
notifeeLib.default.stopForegroundService();
|
|
153
186
|
foregroundServiceStartedRef.current = false;
|
|
154
187
|
}
|
|
155
188
|
};
|