@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,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Call,
|
|
2
3
|
CallingState,
|
|
3
4
|
StreamVideoClient,
|
|
4
5
|
videoLoggerSystem,
|
|
@@ -14,15 +15,30 @@ import {
|
|
|
14
15
|
getExpoNotificationsLibNoThrow,
|
|
15
16
|
getFirebaseMessagingLib,
|
|
16
17
|
getFirebaseMessagingLibNoThrow,
|
|
18
|
+
getIncomingCallForegroundServiceTypes,
|
|
17
19
|
getNotifeeLibThrowIfNotInstalledForPush,
|
|
18
20
|
type NotifeeLib,
|
|
19
21
|
} from './libs';
|
|
20
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
pushAcceptedIncomingCallCId$,
|
|
24
|
+
pushAndroidBackgroundDeliveredIncomingCallCId$,
|
|
25
|
+
pushNonRingingCallData$,
|
|
26
|
+
pushRejectedIncomingCallCId$,
|
|
27
|
+
pushTappedIncomingCallCId$,
|
|
28
|
+
} from './internal/rxSubjects';
|
|
21
29
|
import { pushUnsubscriptionCallbacks } from './internal/constants';
|
|
22
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
canAddPushWSSubscriptionsRef,
|
|
32
|
+
clearPushWSEventSubscriptions,
|
|
33
|
+
processCallFromPushInBackground,
|
|
34
|
+
shouldCallBeEnded,
|
|
35
|
+
} from './internal/utils';
|
|
23
36
|
import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
|
|
37
|
+
import { getAndroidDefaultRingtoneUrl } from '../getAndroidDefaultRingtoneUrl';
|
|
24
38
|
import { StreamVideoRN } from '../StreamVideoRN';
|
|
25
|
-
|
|
39
|
+
|
|
40
|
+
const ACCEPT_CALL_ACTION_ID = 'accept';
|
|
41
|
+
const DECLINE_CALL_ACTION_ID = 'decline';
|
|
26
42
|
|
|
27
43
|
type PushConfig = NonNullable<StreamVideoConfig['push']>;
|
|
28
44
|
|
|
@@ -91,10 +107,11 @@ export async function initAndroidPushToken(
|
|
|
91
107
|
await setDeviceToken(token);
|
|
92
108
|
}
|
|
93
109
|
}
|
|
94
|
-
|
|
95
|
-
const messaging =
|
|
96
|
-
|
|
97
|
-
|
|
110
|
+
// TODO: remove the incomingCallChannel check and find a better way once we have telecom integration for android
|
|
111
|
+
const messaging =
|
|
112
|
+
pushConfig.isExpo && !pushConfig.android.incomingCallChannel
|
|
113
|
+
? getFirebaseMessagingLibNoThrow(true)
|
|
114
|
+
: getFirebaseMessagingLib();
|
|
98
115
|
if (messaging) {
|
|
99
116
|
logger.debug(`setting firebase token listeners`);
|
|
100
117
|
const unsubscribe = messaging().onTokenRefresh((refreshedToken) =>
|
|
@@ -110,10 +127,10 @@ export async function initAndroidPushToken(
|
|
|
110
127
|
* Creates notification from the push message data.
|
|
111
128
|
* For Ringing and Non-Ringing calls.
|
|
112
129
|
*/
|
|
113
|
-
|
|
114
130
|
export const firebaseDataHandler = async (
|
|
115
131
|
data: FirebaseMessagingTypes.RemoteMessage['data'],
|
|
116
132
|
) => {
|
|
133
|
+
if (Platform.OS !== 'android') return;
|
|
117
134
|
/* Example data from firebase
|
|
118
135
|
"message": {
|
|
119
136
|
"data": {
|
|
@@ -129,248 +146,227 @@ export const firebaseDataHandler = async (
|
|
|
129
146
|
// other stuff
|
|
130
147
|
}
|
|
131
148
|
*/
|
|
132
|
-
if (Platform.OS !== 'android') return;
|
|
133
|
-
|
|
134
|
-
const logger = videoLoggerSystem.getLogger('firebaseDataHandler');
|
|
135
149
|
const pushConfig = StreamVideoRN.getConfig().push;
|
|
136
150
|
if (!pushConfig || !data || data.sender !== 'stream.video') {
|
|
137
151
|
return;
|
|
138
152
|
}
|
|
153
|
+
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
|
|
154
|
+
const notifee = notifeeLib.default;
|
|
155
|
+
const settings = await notifee.getNotificationSettings();
|
|
156
|
+
if (settings.authorizationStatus !== 1) {
|
|
157
|
+
const logger = videoLoggerSystem.getLogger('firebaseDataHandler');
|
|
158
|
+
logger.debug(
|
|
159
|
+
`Notification permission not granted, unable to post ${data.type} notifications`,
|
|
160
|
+
);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
139
163
|
|
|
140
164
|
if (data.type === 'call.ring') {
|
|
141
165
|
const call_cid = data.call_cid as string;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
`call_cid is not provided, skipping the call.ring notification`,
|
|
145
|
-
);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
166
|
+
const created_by_id = data.created_by_id as string;
|
|
167
|
+
const receiver_id = data.receiver_id as string;
|
|
148
168
|
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
logger.warn(
|
|
152
|
-
`Cannot post notifications, skipping the call.ring notification`,
|
|
153
|
-
);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
169
|
+
const video_client = await pushConfig.createStreamVideoClient();
|
|
170
|
+
await video_client?.onRingingCall(call_cid);
|
|
156
171
|
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
172
|
+
const shouldCallBeClosed = (callToCheck: Call) => {
|
|
173
|
+
const { mustEndCall } = shouldCallBeEnded(
|
|
174
|
+
callToCheck,
|
|
175
|
+
created_by_id,
|
|
176
|
+
receiver_id,
|
|
161
177
|
);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const shouldRejectCallWhenBusy = client['rejectCallWhenBusy'] ?? false;
|
|
166
|
-
if (callingx.hasRegisteredCall() && shouldRejectCallWhenBusy) {
|
|
167
|
-
logger.debug(
|
|
168
|
-
`registered call found, skipping the call.ring notification`,
|
|
169
|
-
);
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
178
|
+
return mustEndCall;
|
|
179
|
+
};
|
|
172
180
|
|
|
181
|
+
const canListenToWS = () =>
|
|
182
|
+
canAddPushWSSubscriptionsRef.current &&
|
|
183
|
+
AppState.currentState !== 'active';
|
|
173
184
|
const asForegroundService = canListenToWS();
|
|
174
185
|
|
|
175
|
-
const callerName = data.created_by_display_name as string;
|
|
176
|
-
const hasVideo = data.video === 'true';
|
|
177
|
-
|
|
178
186
|
if (asForegroundService) {
|
|
179
187
|
// Listen to call events from WS through fg service
|
|
180
188
|
// note: this will replace the current empty fg service runner
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
resolve(undefined);
|
|
190
|
-
stopTask();
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
(async () => {
|
|
194
|
-
try {
|
|
195
|
-
const _client = await pushConfig.createStreamVideoClient();
|
|
196
|
-
if (!_client) {
|
|
197
|
-
logger.debug(
|
|
198
|
-
`Closing fg service as there is no client to create from push config`,
|
|
199
|
-
);
|
|
200
|
-
finishBackgroundTask();
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const callFromPush = await _client.onRingingCall(call_cid);
|
|
205
|
-
const { mustEndCall, endCallReason } = shouldCallBeClosed(
|
|
206
|
-
callFromPush,
|
|
207
|
-
data,
|
|
189
|
+
notifee.registerForegroundService(() => {
|
|
190
|
+
return new Promise(async () => {
|
|
191
|
+
const client = await pushConfig.createStreamVideoClient();
|
|
192
|
+
if (!client) {
|
|
193
|
+
videoLoggerSystem
|
|
194
|
+
.getLogger('firebaseMessagingOnMessageHandler')
|
|
195
|
+
.debug(
|
|
196
|
+
`Closing fg service as there is no client to create from push config`,
|
|
208
197
|
);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
198
|
+
notifee.stopForegroundService();
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const callFromPush = await client.onRingingCall(call_cid);
|
|
202
|
+
let _shouldCallBeClosed = shouldCallBeClosed(callFromPush);
|
|
203
|
+
if (_shouldCallBeClosed) {
|
|
204
|
+
videoLoggerSystem
|
|
205
|
+
.getLogger('firebaseMessagingOnMessageHandler')
|
|
206
|
+
.debug(
|
|
207
|
+
`Closing fg service callCid: ${call_cid} shouldCallBeClosed: ${_shouldCallBeClosed}`,
|
|
208
|
+
);
|
|
209
|
+
notifee.stopForegroundService();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const unsubscribeFunctions: Array<() => void> = [];
|
|
213
|
+
// check if service needs to be closed if accept/decline event was done on another device
|
|
214
|
+
const unsubscribe = callFromPush.on('all', (event) => {
|
|
215
|
+
const _canListenToWS = canListenToWS();
|
|
216
|
+
if (!_canListenToWS) {
|
|
217
|
+
videoLoggerSystem
|
|
218
|
+
.getLogger('firebaseMessagingOnMessageHandler')
|
|
219
|
+
.debug(
|
|
220
|
+
`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS}`,
|
|
221
|
+
{ event },
|
|
212
222
|
);
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
223
|
+
unsubscribeFunctions.forEach((fn) => fn());
|
|
224
|
+
notifee.stopForegroundService();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
_shouldCallBeClosed = shouldCallBeClosed(callFromPush);
|
|
228
|
+
if (_shouldCallBeClosed) {
|
|
229
|
+
videoLoggerSystem
|
|
230
|
+
.getLogger('firebaseMessagingOnMessageHandler')
|
|
231
|
+
.debug(
|
|
232
|
+
`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS} shouldCallBeClosed: ${_shouldCallBeClosed}`,
|
|
233
|
+
{ event },
|
|
218
234
|
);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const unsubscribeFunctions: Array<() => void> = [];
|
|
224
|
-
// check if service needs to be closed if accept/decline event was done on another device
|
|
225
|
-
const unsubscribe = callFromPush.on('all', (event) => {
|
|
226
|
-
const _canListenToWS = canListenToWS();
|
|
227
|
-
if (!_canListenToWS) {
|
|
228
|
-
logger.debug(
|
|
229
|
-
`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS}`,
|
|
230
|
-
{ event },
|
|
231
|
-
);
|
|
232
|
-
unsubscribeFunctions.forEach((fn) => fn());
|
|
233
|
-
|
|
234
|
-
finishBackgroundTask();
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const {
|
|
239
|
-
mustEndCall: mustEndCallFromEvent,
|
|
240
|
-
endCallReason: endCallReasonFromEvent,
|
|
241
|
-
} = shouldCallBeClosed(callFromPush, data);
|
|
242
|
-
if (mustEndCallFromEvent) {
|
|
243
|
-
logger.debug(
|
|
244
|
-
`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS} shouldCallBeClosed`,
|
|
245
|
-
{ event },
|
|
246
|
-
);
|
|
247
|
-
unsubscribeFunctions.forEach((fn) => fn());
|
|
248
|
-
|
|
249
|
-
finishBackgroundTask();
|
|
250
|
-
callingx.endCallWithReason(call_cid, endCallReasonFromEvent);
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
// check if service needs to be closed if call was left
|
|
255
|
-
const stateSubscription =
|
|
256
|
-
callFromPush.state.callingState$.subscribe((callingState) => {
|
|
257
|
-
if (
|
|
258
|
-
callingState === CallingState.IDLE ||
|
|
259
|
-
callingState === CallingState.LEFT
|
|
260
|
-
) {
|
|
261
|
-
logger.debug(
|
|
262
|
-
`Closing fg service from callingState callCid: ${call_cid} callingState: ${callingState}`,
|
|
263
|
-
);
|
|
264
|
-
unsubscribeFunctions.forEach((fn) => fn());
|
|
265
|
-
callingx.log(
|
|
266
|
-
`Ending call with callCid: ${call_cid} callingState: ${callingState}`,
|
|
267
|
-
'debug',
|
|
268
|
-
);
|
|
269
|
-
finishBackgroundTask();
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
const endCallSubscription = callingx.addEventListener(
|
|
274
|
-
'endCall',
|
|
275
|
-
async ({ callId }: { callId: string }) => {
|
|
276
|
-
unsubscribeFunctions.forEach((fn) => fn());
|
|
277
|
-
try {
|
|
278
|
-
await callFromPush.leave({
|
|
279
|
-
reject: true,
|
|
280
|
-
reason: 'decline',
|
|
281
|
-
});
|
|
282
|
-
} catch (error) {
|
|
283
|
-
logger.error(
|
|
284
|
-
`Failed to leave call with callCid: ${call_cid} error: ${error}`,
|
|
285
|
-
);
|
|
286
|
-
} finally {
|
|
287
|
-
callingx.log(
|
|
288
|
-
`Ending call with callCid: ${call_cid} callId: ${callId}`,
|
|
289
|
-
'debug',
|
|
290
|
-
);
|
|
291
|
-
finishBackgroundTask();
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
);
|
|
295
|
-
|
|
296
|
-
//stop background task when app comes to foreground
|
|
297
|
-
const appStateSubscription = AppState.addEventListener(
|
|
298
|
-
'change',
|
|
299
|
-
(nextAppState) => {
|
|
300
|
-
const _canListenToWS = canListenToWS();
|
|
301
|
-
callingx.log(
|
|
302
|
-
`AppState changed to: ${nextAppState} for callCid: ${call_cid} canListenToWS: ${_canListenToWS}`,
|
|
303
|
-
'debug',
|
|
304
|
-
);
|
|
305
|
-
if (!_canListenToWS) {
|
|
306
|
-
unsubscribeFunctions.forEach((fn) => fn());
|
|
307
|
-
finishBackgroundTask();
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
},
|
|
311
|
-
);
|
|
312
|
-
|
|
313
|
-
unsubscribeFunctions.push(unsubscribe);
|
|
314
|
-
unsubscribeFunctions.push(() => stateSubscription.unsubscribe());
|
|
315
|
-
unsubscribeFunctions.push(() => endCallSubscription.remove());
|
|
316
|
-
unsubscribeFunctions.push(() => appStateSubscription.remove());
|
|
317
|
-
pushUnsubscriptionCallbacks.get(call_cid)?.forEach((cb) => cb());
|
|
318
|
-
pushUnsubscriptionCallbacks.set(call_cid, unsubscribeFunctions);
|
|
319
|
-
} catch (error) {
|
|
320
|
-
callingx.log(
|
|
321
|
-
`Failed to start background task with callCid: ${call_cid} error: ${error}`,
|
|
322
|
-
'error',
|
|
323
|
-
);
|
|
324
|
-
finishBackgroundTask();
|
|
235
|
+
unsubscribeFunctions.forEach((fn) => fn());
|
|
236
|
+
notifee.stopForegroundService();
|
|
325
237
|
}
|
|
326
|
-
})
|
|
238
|
+
});
|
|
239
|
+
// check if service needs to be closed if call was left
|
|
240
|
+
const subscription = callFromPush.state.callingState$.subscribe(
|
|
241
|
+
(callingState) => {
|
|
242
|
+
if (
|
|
243
|
+
callingState === CallingState.IDLE ||
|
|
244
|
+
callingState === CallingState.LEFT
|
|
245
|
+
) {
|
|
246
|
+
videoLoggerSystem
|
|
247
|
+
.getLogger('firebaseMessagingOnMessageHandler')
|
|
248
|
+
.debug(
|
|
249
|
+
`Closing fg service from callingState callCid: ${call_cid} callingState: ${callingState}`,
|
|
250
|
+
);
|
|
251
|
+
unsubscribeFunctions.forEach((fn) => fn());
|
|
252
|
+
notifee.stopForegroundService();
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
);
|
|
256
|
+
unsubscribeFunctions.push(unsubscribe);
|
|
257
|
+
unsubscribeFunctions.push(() => subscription.unsubscribe());
|
|
258
|
+
pushUnsubscriptionCallbacks.get(call_cid)?.forEach((cb) => cb());
|
|
259
|
+
pushUnsubscriptionCallbacks.set(call_cid, unsubscribeFunctions);
|
|
327
260
|
});
|
|
328
261
|
});
|
|
329
262
|
}
|
|
263
|
+
const incomingCallChannel = pushConfig.android.incomingCallChannel;
|
|
264
|
+
const incomingCallNotificationTextGetters =
|
|
265
|
+
pushConfig.android.incomingCallNotificationTextGetters;
|
|
266
|
+
if (!incomingCallChannel || !incomingCallNotificationTextGetters) {
|
|
267
|
+
const logger = videoLoggerSystem.getLogger(
|
|
268
|
+
'firebaseMessagingOnMessageHandler',
|
|
269
|
+
);
|
|
270
|
+
logger.error(
|
|
271
|
+
"Can't show incoming call notification as either or both incomingCallChannel and incomingCallNotificationTextGetters were not provided",
|
|
272
|
+
);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
/*
|
|
276
|
+
* Sound has to be set on channel level for android 8 and above and cant be updated later after creation!
|
|
277
|
+
* For android 7 and below, sound should be set on notification level
|
|
278
|
+
*/
|
|
279
|
+
// set default ringtone if not provided
|
|
280
|
+
if (!incomingCallChannel.sound) {
|
|
281
|
+
incomingCallChannel.sound = await getAndroidDefaultRingtoneUrl();
|
|
282
|
+
}
|
|
283
|
+
await notifee.createChannel(incomingCallChannel);
|
|
284
|
+
const { getTitle, getBody, getAcceptButtonTitle, getDeclineButtonTitle } =
|
|
285
|
+
incomingCallNotificationTextGetters;
|
|
286
|
+
const createdUserName = data.created_by_display_name as string;
|
|
330
287
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
288
|
+
const title = getTitle(createdUserName);
|
|
289
|
+
const body = getBody(createdUserName);
|
|
290
|
+
|
|
291
|
+
videoLoggerSystem
|
|
292
|
+
.getLogger('firebaseMessagingOnMessageHandler')
|
|
293
|
+
.debug(
|
|
294
|
+
`Displaying incoming call notification with callCid: ${call_cid} title: ${title} body: ${body} asForegroundService: ${asForegroundService}`,
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
const channelId = incomingCallChannel.id;
|
|
298
|
+
await notifee.displayNotification({
|
|
299
|
+
id: call_cid,
|
|
300
|
+
title: getTitle(createdUserName),
|
|
301
|
+
body: getBody(createdUserName),
|
|
302
|
+
data,
|
|
303
|
+
android: {
|
|
304
|
+
channelId,
|
|
305
|
+
smallIcon: pushConfig.android.smallIcon,
|
|
306
|
+
importance: 4, // high importance
|
|
307
|
+
foregroundServiceTypes: getIncomingCallForegroundServiceTypes(),
|
|
308
|
+
asForegroundService,
|
|
309
|
+
ongoing: true,
|
|
310
|
+
sound: incomingCallChannel.sound,
|
|
311
|
+
vibrationPattern: incomingCallChannel.vibrationPattern,
|
|
312
|
+
loopSound: true,
|
|
313
|
+
pressAction: {
|
|
314
|
+
id: 'default',
|
|
315
|
+
launchActivity: 'default', // open the app when the notification is pressed
|
|
316
|
+
},
|
|
317
|
+
actions: [
|
|
318
|
+
{
|
|
319
|
+
title: getDeclineButtonTitle?.() ?? 'Decline',
|
|
320
|
+
pressAction: {
|
|
321
|
+
id: DECLINE_CALL_ACTION_ID,
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
title: getAcceptButtonTitle?.() ?? 'Accept',
|
|
326
|
+
pressAction: {
|
|
327
|
+
id: ACCEPT_CALL_ACTION_ID,
|
|
328
|
+
launchActivity: 'default', // open the app when the notification is pressed
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
],
|
|
332
|
+
category: notifeeLib.AndroidCategory.CALL,
|
|
333
|
+
fullScreenAction: {
|
|
334
|
+
id: 'stream_ringing_incoming_call',
|
|
335
|
+
},
|
|
336
|
+
timeoutAfter: 60000, // 60 seconds, after which the notification will be dismissed automatically
|
|
337
|
+
},
|
|
338
|
+
});
|
|
340
339
|
|
|
341
340
|
if (asForegroundService) {
|
|
342
341
|
// no need to check if call has be closed as that will be handled by the fg service
|
|
343
342
|
return;
|
|
344
343
|
}
|
|
345
344
|
|
|
345
|
+
// check if call needs to be closed if accept/decline event was done
|
|
346
|
+
// before the notification was shown
|
|
347
|
+
const client = await pushConfig.createStreamVideoClient();
|
|
348
|
+
if (!client) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
346
351
|
const callFromPush = await client.onRingingCall(call_cid);
|
|
347
352
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
);
|
|
356
|
-
callingx.endCallWithReason(call_cid, endCallReason);
|
|
353
|
+
if (shouldCallBeClosed(callFromPush)) {
|
|
354
|
+
videoLoggerSystem
|
|
355
|
+
.getLogger('firebaseMessagingOnMessageHandler')
|
|
356
|
+
.debug(
|
|
357
|
+
`Removing incoming call notification immediately with callCid: ${call_cid} as it should be closed`,
|
|
358
|
+
);
|
|
359
|
+
notifee.cancelDisplayedNotification(call_cid);
|
|
357
360
|
}
|
|
358
361
|
} else {
|
|
359
|
-
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
|
|
360
|
-
const notifee = notifeeLib.default;
|
|
361
|
-
const settings = await notifee.getNotificationSettings();
|
|
362
|
-
if (settings.authorizationStatus !== 1) {
|
|
363
|
-
logger.debug(
|
|
364
|
-
`Notification permission not granted, unable to post ${data.type} notifications`,
|
|
365
|
-
);
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
362
|
// the other types are call.live_started and call.notification
|
|
370
363
|
const callChannel = pushConfig.android.callChannel;
|
|
371
364
|
const callNotificationTextGetters =
|
|
372
365
|
pushConfig.android.callNotificationTextGetters;
|
|
373
366
|
if (!callChannel || !callNotificationTextGetters) {
|
|
367
|
+
const logger = videoLoggerSystem.getLogger(
|
|
368
|
+
'firebaseMessagingOnMessageHandler',
|
|
369
|
+
);
|
|
374
370
|
logger.debug(
|
|
375
371
|
"Can't show call notification as either or both callChannel and callNotificationTextGetters is not provided",
|
|
376
372
|
);
|
|
@@ -386,12 +382,14 @@ export const firebaseDataHandler = async (
|
|
|
386
382
|
const title = getTitle(type, createdUserName);
|
|
387
383
|
const body = getBody(type, createdUserName);
|
|
388
384
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
385
|
+
videoLoggerSystem
|
|
386
|
+
.getLogger('firebaseMessagingOnMessageHandler')
|
|
387
|
+
.debug(
|
|
388
|
+
`Displaying NonRingingPushEvent ${type} notification with title: ${title} body: ${body}`,
|
|
389
|
+
);
|
|
392
390
|
await notifee.displayNotification({
|
|
393
|
-
title,
|
|
394
|
-
body,
|
|
391
|
+
title: getTitle(type, createdUserName),
|
|
392
|
+
body: getBody(type, createdUserName),
|
|
395
393
|
data,
|
|
396
394
|
android: {
|
|
397
395
|
sound: callChannel.sound,
|
|
@@ -411,10 +409,16 @@ export const firebaseDataHandler = async (
|
|
|
411
409
|
}
|
|
412
410
|
};
|
|
413
411
|
|
|
414
|
-
export const onAndroidNotifeeEvent = async ({
|
|
412
|
+
export const onAndroidNotifeeEvent = async ({
|
|
413
|
+
event,
|
|
414
|
+
isBackground,
|
|
415
|
+
}: {
|
|
416
|
+
event: Event;
|
|
417
|
+
isBackground: boolean;
|
|
418
|
+
}) => {
|
|
415
419
|
if (Platform.OS !== 'android') return;
|
|
416
420
|
const { type, detail } = event;
|
|
417
|
-
const { notification } = detail;
|
|
421
|
+
const { notification, pressAction } = detail;
|
|
418
422
|
const notificationId = notification?.id;
|
|
419
423
|
const data = notification?.data;
|
|
420
424
|
const pushConfig = StreamVideoRN.getConfig().push;
|
|
@@ -430,14 +434,92 @@ export const onAndroidNotifeeEvent = async ({ event }: { event: Event }) => {
|
|
|
430
434
|
// we can safely cast to string because the data is from "stream.video"
|
|
431
435
|
const call_cid = data.call_cid as string;
|
|
432
436
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
437
|
+
if (data.type === 'call.ring') {
|
|
438
|
+
// check if we have observers for the call cid (this means the app is in the foreground state)
|
|
439
|
+
const hasObservers =
|
|
440
|
+
pushAcceptedIncomingCallCId$.observed &&
|
|
441
|
+
pushRejectedIncomingCallCId$.observed;
|
|
442
|
+
|
|
443
|
+
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
|
|
444
|
+
const notifee = notifeeLib.default;
|
|
445
|
+
// Check if we need to decline the call
|
|
446
|
+
const didPressDecline =
|
|
447
|
+
type === notifeeLib.EventType.ACTION_PRESS &&
|
|
448
|
+
pressAction?.id === DECLINE_CALL_ACTION_ID;
|
|
449
|
+
const didDismiss = type === notifeeLib.EventType.DISMISSED;
|
|
450
|
+
const mustDecline = didPressDecline || didDismiss;
|
|
451
|
+
// Check if we need to accept the call
|
|
452
|
+
const mustAccept =
|
|
453
|
+
type === notifeeLib.EventType.ACTION_PRESS &&
|
|
454
|
+
pressAction?.id === ACCEPT_CALL_ACTION_ID;
|
|
455
|
+
|
|
456
|
+
if (
|
|
457
|
+
mustAccept ||
|
|
458
|
+
mustDecline ||
|
|
459
|
+
type === notifeeLib.EventType.ACTION_PRESS
|
|
460
|
+
) {
|
|
461
|
+
videoLoggerSystem
|
|
462
|
+
.getLogger('onAndroidNotifeeEvent')
|
|
463
|
+
.debug(
|
|
464
|
+
`clearPushWSEventSubscriptions for callCId: ${call_cid} mustAccept: ${mustAccept} mustDecline: ${mustDecline}`,
|
|
465
|
+
);
|
|
466
|
+
clearPushWSEventSubscriptions(call_cid);
|
|
467
|
+
notifee.stopForegroundService();
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (mustAccept) {
|
|
471
|
+
videoLoggerSystem
|
|
472
|
+
.getLogger('onAndroidNotifeeEvent')
|
|
473
|
+
.debug(`pushAcceptedIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
474
|
+
pushAcceptedIncomingCallCId$.next(call_cid);
|
|
475
|
+
// NOTE: accept will be handled by the app with rxjs observers as the app will go to foreground always
|
|
476
|
+
} else if (mustDecline) {
|
|
477
|
+
videoLoggerSystem
|
|
478
|
+
.getLogger('onAndroidNotifeeEvent')
|
|
479
|
+
.debug(`pushRejectedIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
480
|
+
pushRejectedIncomingCallCId$.next(call_cid);
|
|
481
|
+
if (hasObservers) {
|
|
482
|
+
// if we had observers we can return here as the observers will handle the call as the app is in the foreground state
|
|
483
|
+
videoLoggerSystem
|
|
484
|
+
.getLogger('onAndroidNotifeeEvent')
|
|
485
|
+
.debug(
|
|
486
|
+
`Skipped processCallFromPushInBackground for Declining call with callCId: ${call_cid} as the app is in the foreground state`,
|
|
487
|
+
);
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
videoLoggerSystem
|
|
491
|
+
.getLogger('onAndroidNotifeeEvent')
|
|
492
|
+
.debug(
|
|
493
|
+
`start processCallFromPushInBackground - Declining call with callCId: ${call_cid}`,
|
|
494
|
+
);
|
|
495
|
+
await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
|
|
496
|
+
} else {
|
|
497
|
+
if (type === notifeeLib.EventType.PRESS) {
|
|
498
|
+
videoLoggerSystem
|
|
499
|
+
.getLogger('onAndroidNotifeeEvent')
|
|
500
|
+
.debug(`pushTappedIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
501
|
+
pushTappedIncomingCallCId$.next(call_cid);
|
|
502
|
+
// pressed state will be handled by the app with rxjs observers as the app will go to foreground always
|
|
503
|
+
} else if (isBackground && type === notifeeLib.EventType.DELIVERED) {
|
|
504
|
+
videoLoggerSystem
|
|
505
|
+
.getLogger('onAndroidNotifeeEvent')
|
|
506
|
+
.debug(
|
|
507
|
+
`pushAndroidBackgroundDeliveredIncomingCallCId$ added with callCId: ${call_cid}`,
|
|
508
|
+
);
|
|
509
|
+
pushAndroidBackgroundDeliveredIncomingCallCId$.next(call_cid);
|
|
510
|
+
// background delivered state will be handled by the app with rxjs observers as processing needs to happen only when app is opened
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
} else {
|
|
514
|
+
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
|
|
515
|
+
if (type === notifeeLib.EventType.PRESS) {
|
|
516
|
+
videoLoggerSystem
|
|
517
|
+
.getLogger('onAndroidNotifeeEvent')
|
|
518
|
+
.debug(`onTapNonRingingCallNotification with callCId: ${call_cid}`);
|
|
519
|
+
pushConfig.onTapNonRingingCallNotification?.(
|
|
520
|
+
call_cid,
|
|
521
|
+
data.type as NonRingingPushEvent,
|
|
522
|
+
);
|
|
523
|
+
}
|
|
442
524
|
}
|
|
443
525
|
};
|