@stream-io/video-react-native-sdk 1.31.1-beta.0 → 1.31.1
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 +11 -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/Participant/ParticipantView/ParticipantLabel.js +2 -6
- package/dist/commonjs/components/Participant/ParticipantView/ParticipantLabel.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 -35
- package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/commonjs/utils/internal/registerSDKGlobals.js +3 -53
- package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/commonjs/utils/push/android.js +202 -135
- 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 +53 -71
- 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/Participant/ParticipantView/ParticipantLabel.js +2 -6
- package/dist/module/components/Participant/ParticipantView/ParticipantLabel.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 -35
- package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/module/utils/internal/registerSDKGlobals.js +3 -53
- package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/module/utils/push/android.js +204 -137
- 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 +50 -67
- 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/Participant/ParticipantView/ParticipantLabel.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 -22
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/types.d.ts +25 -59
- package/dist/typescript/utils/StreamVideoRN/types.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 +8 -14
- 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/firebaseMessaging/index.d.ts +2 -16
- package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
- 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/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 +16 -11
- package/src/components/Participant/ParticipantView/ParticipantLabel.tsx +2 -7
- 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 -42
- package/src/utils/StreamVideoRN/types.ts +25 -61
- package/src/utils/internal/registerSDKGlobals.ts +4 -52
- package/src/utils/push/android.ts +311 -198
- 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 +64 -108
- 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 -144
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
- package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js +0 -68
- package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js.map +0 -1
- package/dist/commonjs/utils/internal/callingx/callingx.js +0 -150
- 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 -105
- package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +0 -1
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +0 -137
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
- package/dist/module/utils/internal/callingx/audioSessionPromise.js +0 -61
- package/dist/module/utils/internal/callingx/audioSessionPromise.js.map +0 -1
- package/dist/module/utils/internal/callingx/callingx.js +0 -140
- 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 -99
- 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/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 -18
- 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 -189
- package/src/utils/internal/callingx/audioSessionPromise.ts +0 -65
- package/src/utils/internal/callingx/callingx.ts +0 -194
- package/src/utils/keepCallAliveHeadlessTask.ts +0 -54
- package/src/utils/push/libs/callingx.ts +0 -89
- package/src/utils/push/setupCallingExpEvents.ts +0 -135
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import pushLogoutCallbacks from '../internal/pushLogoutCallback';
|
|
2
2
|
import newNotificationCallbacks from '../internal/newNotificationCallbacks';
|
|
3
|
+
import { setupIosCallKeepEvents } from '../push/setupIosCallKeepEvents';
|
|
3
4
|
import { setupIosVoipPushEvents } from '../push/setupIosVoipPushEvents';
|
|
4
|
-
import { setupCallingExpEvents } from '../push/setupCallingExpEvents';
|
|
5
|
-
import { extractCallingExpOptions, getCallingxLib } from '../push/libs/callingx';
|
|
6
5
|
import { NativeModules, Platform } from 'react-native';
|
|
7
|
-
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
8
6
|
|
|
9
7
|
// Utility type for deep partial
|
|
10
8
|
|
|
@@ -29,7 +27,10 @@ const DEFAULT_STREAM_VIDEO_CONFIG = {
|
|
|
29
27
|
android: {
|
|
30
28
|
channel: {
|
|
31
29
|
id: 'stream_call_foreground_service',
|
|
32
|
-
name: '
|
|
30
|
+
name: 'To keep calls alive',
|
|
31
|
+
lights: false,
|
|
32
|
+
vibration: false,
|
|
33
|
+
importance: 3
|
|
33
34
|
},
|
|
34
35
|
notificationTexts: {
|
|
35
36
|
title: 'Call in progress',
|
|
@@ -51,6 +52,15 @@ export class StreamVideoRN {
|
|
|
51
52
|
static updateConfig(updateConfig) {
|
|
52
53
|
this.config = deepMerge(this.config, updateConfig);
|
|
53
54
|
}
|
|
55
|
+
static updateAndroidIncomingCallChannel(updateChannel) {
|
|
56
|
+
const prevChannel = this.config.push?.android?.incomingCallChannel;
|
|
57
|
+
if (prevChannel) {
|
|
58
|
+
this.config.push.android.incomingCallChannel = {
|
|
59
|
+
...prevChannel,
|
|
60
|
+
...updateChannel
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
54
64
|
|
|
55
65
|
/**
|
|
56
66
|
* Set the push config for StreamVideoRN.
|
|
@@ -64,28 +74,7 @@ export class StreamVideoRN {
|
|
|
64
74
|
* import App from './App';
|
|
65
75
|
* // Set push config
|
|
66
76
|
* const pushConfig = {}; // construct your config
|
|
67
|
-
*
|
|
68
|
-
* const callingExpOptions = {
|
|
69
|
-
* ios: {
|
|
70
|
-
* callsHistory: true,
|
|
71
|
-
* displayCallTimeout: 60000,
|
|
72
|
-
* sound: 'ringtone',
|
|
73
|
-
* imageName: 'callkit_icon',
|
|
74
|
-
* },
|
|
75
|
-
* android: {
|
|
76
|
-
* incomingChannel: {
|
|
77
|
-
* id: 'stream_incoming_call_notifications',
|
|
78
|
-
* name: 'Call notifications',
|
|
79
|
-
* vibration: true,
|
|
80
|
-
* sound: 'default',
|
|
81
|
-
* },
|
|
82
|
-
* titleTransformer: (memberName: string, incoming: boolean) =>
|
|
83
|
-
* incoming
|
|
84
|
-
* ? `${memberName} is calling you`
|
|
85
|
-
* : `You are calling ${memberName}`,
|
|
86
|
-
* },
|
|
87
|
-
* };
|
|
88
|
-
* StreamVideoRN.setPushConfig(pushConfig, callingExpOptions);
|
|
77
|
+
* StreamVideoRN.setPushConfig(pushConfig);
|
|
89
78
|
* AppRegistry.registerComponent('app', () => App);
|
|
90
79
|
*/
|
|
91
80
|
static setPushConfig(pushConfig) {
|
|
@@ -93,16 +82,13 @@ export class StreamVideoRN {
|
|
|
93
82
|
// Ignoring this config as push config was already set
|
|
94
83
|
return;
|
|
95
84
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const options = extractCallingExpOptions(this.config);
|
|
101
|
-
callingx.setup(options);
|
|
102
|
-
} catch {
|
|
103
|
-
throw new Error('react-native-callingx library is not installed. Please check the installation instructions: https://getstream.io/video/docs/react-native/incoming-calls/ringing-setup/react-native/.');
|
|
85
|
+
if (__DEV__ && (pushConfig.navigateAcceptCall || pushConfig.navigateToIncomingCall)) {
|
|
86
|
+
throw new Error(`Support for navigateAcceptCall or navigateToIncomingCall in pushConfig has been removed.
|
|
87
|
+
Please watch for incoming and outgoing calls in the root component of your app.
|
|
88
|
+
Please see https://getstream.io/video/docs/react-native/advanced/ringing-calls/#watch-for-incoming-and-outgoing-calls for more information.`);
|
|
104
89
|
}
|
|
105
|
-
|
|
90
|
+
this.config.push = pushConfig;
|
|
91
|
+
setupIosCallKeepEvents(pushConfig);
|
|
106
92
|
setupIosVoipPushEvents(pushConfig);
|
|
107
93
|
}
|
|
108
94
|
static getConfig() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["pushLogoutCallbacks","newNotificationCallbacks","
|
|
1
|
+
{"version":3,"names":["pushLogoutCallbacks","newNotificationCallbacks","setupIosCallKeepEvents","setupIosVoipPushEvents","NativeModules","Platform","deepMerge","target","source","result","key","undefined","Array","isArray","DEFAULT_STREAM_VIDEO_CONFIG","foregroundService","android","channel","id","name","lights","vibration","importance","notificationTexts","title","body","taskToRun","Promise","StreamVideoRN","config","busyToneTimeout","updateConfig","updateAndroidIncomingCallChannel","updateChannel","prevChannel","push","incomingCallChannel","setPushConfig","pushConfig","__DEV__","navigateAcceptCall","navigateToIncomingCall","Error","getConfig","onPushLogout","current","all","map","callback","then","resolve","clearPushLogoutCallbacks","addOnNewCallNotificationListener","filter","cb","playBusyTone","StreamVideoReactNative","stopBusyTone","androidHasAudioOutputHardware","OS","hasAudioOutputHardware","androidHasMicrophoneHardware","hasMicrophoneHardware","androidHasCameraHardware","hasCameraHardware"],"sourceRoot":"../../../../src","sources":["utils/StreamVideoRN/index.ts"],"mappings":"AACA,OAAOA,mBAAmB,MAAM,gCAAgC;AAChE,OAAOC,wBAAwB,MAExB,sCAAsC;AAC7C,SAASC,sBAAsB,QAAQ,gCAAgC;AACvE,SAASC,sBAAsB,QAAQ,gCAAgC;AACvE,SAASC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;;AAEtD;;AAKA;AACA,SAASC,SAASA,CAChBC,MAAS,EACTC,MAAsB,EACnB;EACH,MAAMC,MAAM,GAAG;IAAE,GAAGF;EAAO,CAAC;EAE5B,KAAK,MAAMG,GAAG,IAAIF,MAAM,EAAE;IACxB,IAAIA,MAAM,CAACE,GAAG,CAAC,KAAKC,SAAS,EAAE;MA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C,CAAC;EACjE;AACF","ignoreList":[]}
|
|
@@ -1,68 +1,18 @@
|
|
|
1
1
|
import { NativeModules, PermissionsAndroid, Platform } from 'react-native';
|
|
2
|
-
import { getCallingxLibIfAvailable } from '../push/libs/callingx';
|
|
3
|
-
import { endCallingxCall, registerOutgoingCall, joinCallingxCall } from './callingx/callingx';
|
|
4
2
|
const StreamInCallManagerNativeModule = NativeModules.StreamInCallManager;
|
|
5
3
|
const StreamVideoReactNativeModule = NativeModules.StreamVideoReactNative;
|
|
6
|
-
const CallingxModule = getCallingxLibIfAvailable();
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Checks if StreamInCallManager should be bypassed because CallKit is handling
|
|
10
|
-
* the audio session via CallingX.
|
|
11
|
-
*
|
|
12
|
-
* On iOS, when CallingX is set up and has a registered call, the audio session
|
|
13
|
-
* is managed by CallKit through CallingxImpl.swift.
|
|
14
|
-
* In this case, StreamInCallManager should not run to avoid conflicting audio
|
|
15
|
-
* session configurations.
|
|
16
|
-
*/
|
|
17
|
-
const shouldBypassForCallKit = ({
|
|
18
|
-
isRingingTypeCall
|
|
19
|
-
}) => {
|
|
20
|
-
if (Platform.OS !== 'ios') {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
if (!CallingxModule) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
const bypass = CallingxModule.isSetup && (isRingingTypeCall || CallingxModule.isOngoingCallsEnabled);
|
|
27
|
-
return bypass;
|
|
28
|
-
};
|
|
29
4
|
const streamRNVideoSDKGlobals = {
|
|
30
|
-
callingX: {
|
|
31
|
-
joinCall: joinCallingxCall,
|
|
32
|
-
endCall: endCallingxCall,
|
|
33
|
-
registerOutgoingCall: registerOutgoingCall
|
|
34
|
-
},
|
|
35
5
|
callManager: {
|
|
36
6
|
setup: ({
|
|
37
|
-
defaultDevice
|
|
38
|
-
isRingingTypeCall
|
|
7
|
+
defaultDevice
|
|
39
8
|
}) => {
|
|
40
|
-
if (shouldBypassForCallKit({
|
|
41
|
-
isRingingTypeCall
|
|
42
|
-
})) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
9
|
StreamInCallManagerNativeModule.setDefaultAudioDeviceEndpointType(defaultDevice);
|
|
46
10
|
StreamInCallManagerNativeModule.setup();
|
|
47
11
|
},
|
|
48
|
-
start: ({
|
|
49
|
-
isRingingTypeCall
|
|
50
|
-
}) => {
|
|
51
|
-
if (shouldBypassForCallKit({
|
|
52
|
-
isRingingTypeCall
|
|
53
|
-
})) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
12
|
+
start: () => {
|
|
56
13
|
StreamInCallManagerNativeModule.start();
|
|
57
14
|
},
|
|
58
|
-
stop: ({
|
|
59
|
-
isRingingTypeCall
|
|
60
|
-
}) => {
|
|
61
|
-
if (shouldBypassForCallKit({
|
|
62
|
-
isRingingTypeCall
|
|
63
|
-
})) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
15
|
+
stop: () => {
|
|
66
16
|
StreamInCallManagerNativeModule.stop();
|
|
67
17
|
}
|
|
68
18
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","PermissionsAndroid","Platform","
|
|
1
|
+
{"version":3,"names":["NativeModules","PermissionsAndroid","Platform","StreamInCallManagerNativeModule","StreamInCallManager","StreamVideoReactNativeModule","StreamVideoReactNative","streamRNVideoSDKGlobals","callManager","setup","defaultDevice","setDefaultAudioDeviceEndpointType","start","stop","permissions","check","permission","OS","nativeAndroidPermission","PERMISSIONS","CAMERA","RECORD_AUDIO","Boolean","checkPermission","registerSDKGlobals","global","streamRNVideoSDK"],"sourceRoot":"../../../../src","sources":["utils/internal/registerSDKGlobals.ts"],"mappings":"AACA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAE1E,MAAMC,+BAA+B,GAAGH,aAAa,CAACI,mBAAmB;AACzE,MAAMC,4BAA4B,GAAGL,aAAa,CAACM,sBAElD;AAED,MAAMC,uBAAgD,GAAG;EACvDC,WAAW,EAAE;IACXC,KAAK,EAAEA,CAAC;MAAEC;IAAc,CAAC,KAAK;MAC5BP,+BAA+B,CAACQ,iCAAiC,CAC/DD,aACF,CAAC;MACDP,+BAA+B,CAACM,KAAK,CAAC,CAAC;IACzC,CAAC;IACDG,KAAK,EAAEA,CAAA,KAAM;MACXT,+BAA+B,CAACS,KAAK,CAAC,CAAC;IACzC,CAAC;IACDC,IAAI,EAAEA,CAAA,KAAM;MACVV,+BAA+B,CAACU,IAAI,CAAC,CAAC;IACxC;EACF,CAAC;EACDC,WAAW,EAAE;IACXC,KAAK,EAAE,MAAOC,UAAU,IAAK;MAC3B,IAAId,QAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;QAC7B,MAAMC,uBAAuB,GAC3BF,UAAU,KAAK,QAAQ,GACnBf,kBAAkB,CAACkB,WAAW,CAACC,MAAM,GACrCnB,kBAAkB,CAACkB,WAAW,CAACE,YAAY;QACjD,OAAOpB,kBAAkB,CAACc,KAAK,CAACG,uBAAuB,CAAC;MAC1D;;MAEA;MACA,OAAOI,OAAO,CACZ,MAAMjB,4BAA4B,CAACkB,eAAe,GAAGP,UAAU,CACjE,CAAC;IACH;EACF;AACF,CAAC;;AAED;AACA;AACA;AACA,OAAO,SAASQ,kBAAkBA,CAAA,EAAG;EACnC,IAAI,CAACC,MAAM,CAACC,gBAAgB,EAAE;IAC5BD,MAAM,CAACC,gBAAgB,GAAGnB,uBAAuB;EACnD;AACF","ignoreList":[]}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { CallingState, videoLoggerSystem } from '@stream-io/video-client';
|
|
2
2
|
import { AppState, Platform } from 'react-native';
|
|
3
|
-
import { getExpoNotificationsLib, getExpoNotificationsLibNoThrow, getFirebaseMessagingLib, getFirebaseMessagingLibNoThrow, getNotifeeLibThrowIfNotInstalledForPush } from './libs';
|
|
4
|
-
import { pushNonRingingCallData$ } from './internal/rxSubjects';
|
|
3
|
+
import { getExpoNotificationsLib, getExpoNotificationsLibNoThrow, getFirebaseMessagingLib, getFirebaseMessagingLibNoThrow, getIncomingCallForegroundServiceTypes, getNotifeeLibThrowIfNotInstalledForPush } from './libs';
|
|
4
|
+
import { pushAcceptedIncomingCallCId$, pushAndroidBackgroundDeliveredIncomingCallCId$, pushNonRingingCallData$, pushRejectedIncomingCallCId$, pushTappedIncomingCallCId$ } from './internal/rxSubjects';
|
|
5
5
|
import { pushUnsubscriptionCallbacks } from './internal/constants';
|
|
6
|
-
import {
|
|
6
|
+
import { canAddPushWSSubscriptionsRef, clearPushWSEventSubscriptions, processCallFromPushInBackground, shouldCallBeEnded } from './internal/utils';
|
|
7
7
|
import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
|
|
8
|
+
import { getAndroidDefaultRingtoneUrl } from '../getAndroidDefaultRingtoneUrl';
|
|
8
9
|
import { StreamVideoRN } from '../StreamVideoRN';
|
|
9
|
-
|
|
10
|
+
const ACCEPT_CALL_ACTION_ID = 'accept';
|
|
11
|
+
const DECLINE_CALL_ACTION_ID = 'decline';
|
|
10
12
|
let lastFirebaseToken = {
|
|
11
13
|
token: '',
|
|
12
14
|
userId: ''
|
|
@@ -61,7 +63,8 @@ export async function initAndroidPushToken(client, pushConfig, setUnsubscribeLis
|
|
|
61
63
|
await setDeviceToken(token);
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
|
-
|
|
66
|
+
// TODO: remove the incomingCallChannel check and find a better way once we have telecom integration for android
|
|
67
|
+
const messaging = pushConfig.isExpo && !pushConfig.android.incomingCallChannel ? getFirebaseMessagingLibNoThrow(true) : getFirebaseMessagingLib();
|
|
65
68
|
if (messaging) {
|
|
66
69
|
logger.debug(`setting firebase token listeners`);
|
|
67
70
|
const unsubscribe = messaging().onTokenRefresh(refreshedToken => setDeviceToken(refreshedToken));
|
|
@@ -75,8 +78,8 @@ export async function initAndroidPushToken(client, pushConfig, setUnsubscribeLis
|
|
|
75
78
|
* Creates notification from the push message data.
|
|
76
79
|
* For Ringing and Non-Ringing calls.
|
|
77
80
|
*/
|
|
78
|
-
|
|
79
81
|
export const firebaseDataHandler = async data => {
|
|
82
|
+
if (Platform.OS !== 'android') return;
|
|
80
83
|
/* Example data from firebase
|
|
81
84
|
"message": {
|
|
82
85
|
"data": {
|
|
@@ -92,155 +95,174 @@ export const firebaseDataHandler = async data => {
|
|
|
92
95
|
// other stuff
|
|
93
96
|
}
|
|
94
97
|
*/
|
|
95
|
-
if (Platform.OS !== 'android') return;
|
|
96
|
-
const logger = videoLoggerSystem.getLogger('firebaseDataHandler');
|
|
97
98
|
const pushConfig = StreamVideoRN.getConfig().push;
|
|
98
99
|
if (!pushConfig || !data || data.sender !== 'stream.video') {
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
102
|
+
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
|
|
103
|
+
const notifee = notifeeLib.default;
|
|
104
|
+
const settings = await notifee.getNotificationSettings();
|
|
105
|
+
if (settings.authorizationStatus !== 1) {
|
|
106
|
+
const logger = videoLoggerSystem.getLogger('firebaseDataHandler');
|
|
107
|
+
logger.debug(`Notification permission not granted, unable to post ${data.type} notifications`);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
101
110
|
if (data.type === 'call.ring') {
|
|
102
111
|
const call_cid = data.call_cid;
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
const created_by_id = data.created_by_id;
|
|
113
|
+
const receiver_id = data.receiver_id;
|
|
114
|
+
const video_client = await pushConfig.createStreamVideoClient();
|
|
115
|
+
await video_client?.onRingingCall(call_cid);
|
|
116
|
+
const shouldCallBeClosed = callToCheck => {
|
|
117
|
+
const {
|
|
118
|
+
mustEndCall
|
|
119
|
+
} = shouldCallBeEnded(callToCheck, created_by_id, receiver_id);
|
|
120
|
+
return mustEndCall;
|
|
121
|
+
};
|
|
122
|
+
const canListenToWS = () => canAddPushWSSubscriptionsRef.current && AppState.currentState !== 'active';
|
|
110
123
|
const asForegroundService = canListenToWS();
|
|
111
124
|
if (asForegroundService) {
|
|
112
125
|
// Listen to call events from WS through fg service
|
|
113
126
|
// note: this will replace the current empty fg service runner
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
logger.debug(`Closing fg service callCid: ${call_cid} endCallReason: ${endCallReason}`);
|
|
137
|
-
callingx.log(`Ending call with callCid: ${call_cid} endCallReason: ${endCallReason}`, 'debug');
|
|
138
|
-
callingx.endCallWithReason(call_cid, endCallReason);
|
|
139
|
-
resolve(undefined);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const unsubscribeFunctions = [];
|
|
143
|
-
// check if service needs to be closed if accept/decline event was done on another device
|
|
144
|
-
const unsubscribe = callFromPush.on('all', event => {
|
|
145
|
-
const _canListenToWS = canListenToWS();
|
|
146
|
-
if (!_canListenToWS) {
|
|
147
|
-
logger.debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, {
|
|
148
|
-
event
|
|
149
|
-
});
|
|
150
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
151
|
-
finishBackgroundTask();
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const {
|
|
155
|
-
mustEndCall: mustEndCallFromEvent,
|
|
156
|
-
endCallReason: endCallReasonFromEvent
|
|
157
|
-
} = shouldCallBeClosed(callFromPush, data);
|
|
158
|
-
if (mustEndCallFromEvent) {
|
|
159
|
-
logger.debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS} shouldCallBeClosed`, {
|
|
160
|
-
event
|
|
161
|
-
});
|
|
162
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
163
|
-
callingx.endCallWithReason(call_cid, endCallReasonFromEvent);
|
|
164
|
-
resolve(undefined);
|
|
165
|
-
}
|
|
127
|
+
notifee.registerForegroundService(() => {
|
|
128
|
+
return new Promise(async () => {
|
|
129
|
+
const client = await pushConfig.createStreamVideoClient();
|
|
130
|
+
if (!client) {
|
|
131
|
+
videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Closing fg service as there is no client to create from push config`);
|
|
132
|
+
notifee.stopForegroundService();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const callFromPush = await client.onRingingCall(call_cid);
|
|
136
|
+
let _shouldCallBeClosed = shouldCallBeClosed(callFromPush);
|
|
137
|
+
if (_shouldCallBeClosed) {
|
|
138
|
+
videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Closing fg service callCid: ${call_cid} shouldCallBeClosed: ${_shouldCallBeClosed}`);
|
|
139
|
+
notifee.stopForegroundService();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const unsubscribeFunctions = [];
|
|
143
|
+
// check if service needs to be closed if accept/decline event was done on another device
|
|
144
|
+
const unsubscribe = callFromPush.on('all', event => {
|
|
145
|
+
const _canListenToWS = canListenToWS();
|
|
146
|
+
if (!_canListenToWS) {
|
|
147
|
+
videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, {
|
|
148
|
+
event
|
|
166
149
|
});
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
const endCallSubscription = callingx.addEventListener('endCall', async ({
|
|
178
|
-
callId
|
|
179
|
-
}) => {
|
|
180
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
181
|
-
try {
|
|
182
|
-
await callFromPush.leave({
|
|
183
|
-
reject: callFromPush.state.callingState === CallingState.RINGING,
|
|
184
|
-
reason: 'decline'
|
|
185
|
-
});
|
|
186
|
-
} catch (error) {
|
|
187
|
-
logger.error(`Failed to leave call with callCid: ${call_cid} error: ${error}`);
|
|
188
|
-
} finally {
|
|
189
|
-
callingx.log(`Ending call with callCid: ${call_cid} callId: ${callId}`, 'debug');
|
|
190
|
-
resolve(undefined);
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
//stop background task when app comes to foreground
|
|
195
|
-
const appStateSubscription = AppState.addEventListener('change', nextAppState => {
|
|
196
|
-
const _canListenToWS = canListenToWS();
|
|
197
|
-
callingx.log(`AppState changed to: ${nextAppState} for callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, 'debug');
|
|
198
|
-
if (!_canListenToWS) {
|
|
199
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
200
|
-
finishBackgroundTask();
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
150
|
+
unsubscribeFunctions.forEach(fn => fn());
|
|
151
|
+
notifee.stopForegroundService();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
_shouldCallBeClosed = shouldCallBeClosed(callFromPush);
|
|
155
|
+
if (_shouldCallBeClosed) {
|
|
156
|
+
videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS} shouldCallBeClosed: ${_shouldCallBeClosed}`, {
|
|
157
|
+
event
|
|
203
158
|
});
|
|
204
|
-
unsubscribeFunctions.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
159
|
+
unsubscribeFunctions.forEach(fn => fn());
|
|
160
|
+
notifee.stopForegroundService();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
// check if service needs to be closed if call was left
|
|
164
|
+
const subscription = callFromPush.state.callingState$.subscribe(callingState => {
|
|
165
|
+
if (callingState === CallingState.IDLE || callingState === CallingState.LEFT) {
|
|
166
|
+
videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Closing fg service from callingState callCid: ${call_cid} callingState: ${callingState}`);
|
|
167
|
+
unsubscribeFunctions.forEach(fn => fn());
|
|
168
|
+
notifee.stopForegroundService();
|
|
213
169
|
}
|
|
214
|
-
})
|
|
170
|
+
});
|
|
171
|
+
unsubscribeFunctions.push(unsubscribe);
|
|
172
|
+
unsubscribeFunctions.push(() => subscription.unsubscribe());
|
|
173
|
+
pushUnsubscriptionCallbacks.get(call_cid)?.forEach(cb => cb());
|
|
174
|
+
pushUnsubscriptionCallbacks.set(call_cid, unsubscribeFunctions);
|
|
215
175
|
});
|
|
216
176
|
});
|
|
217
177
|
}
|
|
178
|
+
const incomingCallChannel = pushConfig.android.incomingCallChannel;
|
|
179
|
+
const incomingCallNotificationTextGetters = pushConfig.android.incomingCallNotificationTextGetters;
|
|
180
|
+
if (!incomingCallChannel || !incomingCallNotificationTextGetters) {
|
|
181
|
+
const logger = videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler');
|
|
182
|
+
logger.error("Can't show incoming call notification as either or both incomingCallChannel and incomingCallNotificationTextGetters were not provided");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
/*
|
|
186
|
+
* Sound has to be set on channel level for android 8 and above and cant be updated later after creation!
|
|
187
|
+
* For android 7 and below, sound should be set on notification level
|
|
188
|
+
*/
|
|
189
|
+
// set default ringtone if not provided
|
|
190
|
+
if (!incomingCallChannel.sound) {
|
|
191
|
+
incomingCallChannel.sound = await getAndroidDefaultRingtoneUrl();
|
|
192
|
+
}
|
|
193
|
+
await notifee.createChannel(incomingCallChannel);
|
|
194
|
+
const {
|
|
195
|
+
getTitle,
|
|
196
|
+
getBody,
|
|
197
|
+
getAcceptButtonTitle,
|
|
198
|
+
getDeclineButtonTitle
|
|
199
|
+
} = incomingCallNotificationTextGetters;
|
|
200
|
+
const createdUserName = data.created_by_display_name;
|
|
201
|
+
const title = getTitle(createdUserName);
|
|
202
|
+
const body = getBody(createdUserName);
|
|
203
|
+
videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Displaying incoming call notification with callCid: ${call_cid} title: ${title} body: ${body} asForegroundService: ${asForegroundService}`);
|
|
204
|
+
const channelId = incomingCallChannel.id;
|
|
205
|
+
await notifee.displayNotification({
|
|
206
|
+
id: call_cid,
|
|
207
|
+
title: getTitle(createdUserName),
|
|
208
|
+
body: getBody(createdUserName),
|
|
209
|
+
data,
|
|
210
|
+
android: {
|
|
211
|
+
channelId,
|
|
212
|
+
smallIcon: pushConfig.android.smallIcon,
|
|
213
|
+
importance: 4,
|
|
214
|
+
// high importance
|
|
215
|
+
foregroundServiceTypes: getIncomingCallForegroundServiceTypes(),
|
|
216
|
+
asForegroundService,
|
|
217
|
+
ongoing: true,
|
|
218
|
+
sound: incomingCallChannel.sound,
|
|
219
|
+
vibrationPattern: incomingCallChannel.vibrationPattern,
|
|
220
|
+
loopSound: true,
|
|
221
|
+
pressAction: {
|
|
222
|
+
id: 'default',
|
|
223
|
+
launchActivity: 'default' // open the app when the notification is pressed
|
|
224
|
+
},
|
|
225
|
+
actions: [{
|
|
226
|
+
title: getDeclineButtonTitle?.() ?? 'Decline',
|
|
227
|
+
pressAction: {
|
|
228
|
+
id: DECLINE_CALL_ACTION_ID
|
|
229
|
+
}
|
|
230
|
+
}, {
|
|
231
|
+
title: getAcceptButtonTitle?.() ?? 'Accept',
|
|
232
|
+
pressAction: {
|
|
233
|
+
id: ACCEPT_CALL_ACTION_ID,
|
|
234
|
+
launchActivity: 'default' // open the app when the notification is pressed
|
|
235
|
+
}
|
|
236
|
+
}],
|
|
237
|
+
category: notifeeLib.AndroidCategory.CALL,
|
|
238
|
+
fullScreenAction: {
|
|
239
|
+
id: 'stream_ringing_incoming_call'
|
|
240
|
+
},
|
|
241
|
+
timeoutAfter: 60000 // 60 seconds, after which the notification will be dismissed automatically
|
|
242
|
+
}
|
|
243
|
+
});
|
|
218
244
|
if (asForegroundService) {
|
|
219
245
|
// no need to check if call has be closed as that will be handled by the fg service
|
|
220
246
|
return;
|
|
221
247
|
}
|
|
248
|
+
|
|
249
|
+
// check if call needs to be closed if accept/decline event was done
|
|
250
|
+
// before the notification was shown
|
|
251
|
+
const client = await pushConfig.createStreamVideoClient();
|
|
252
|
+
if (!client) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
222
255
|
const callFromPush = await client.onRingingCall(call_cid);
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
} = shouldCallBeClosed(callFromPush, data);
|
|
227
|
-
if (mustEndCall) {
|
|
228
|
-
logger.debug(`Removing incoming call notification immediately with callCid: ${call_cid} as it should be closed`);
|
|
229
|
-
callingx.endCallWithReason(call_cid, endCallReason);
|
|
256
|
+
if (shouldCallBeClosed(callFromPush)) {
|
|
257
|
+
videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Removing incoming call notification immediately with callCid: ${call_cid} as it should be closed`);
|
|
258
|
+
notifee.cancelDisplayedNotification(call_cid);
|
|
230
259
|
}
|
|
231
260
|
} else {
|
|
232
|
-
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
|
|
233
|
-
const notifee = notifeeLib.default;
|
|
234
|
-
const settings = await notifee.getNotificationSettings();
|
|
235
|
-
if (settings.authorizationStatus !== 1) {
|
|
236
|
-
logger.debug(`Notification permission not granted, unable to post ${data.type} notifications`);
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
261
|
// the other types are call.live_started and call.notification
|
|
241
262
|
const callChannel = pushConfig.android.callChannel;
|
|
242
263
|
const callNotificationTextGetters = pushConfig.android.callNotificationTextGetters;
|
|
243
264
|
if (!callChannel || !callNotificationTextGetters) {
|
|
265
|
+
const logger = videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler');
|
|
244
266
|
logger.debug("Can't show call notification as either or both callChannel and callNotificationTextGetters is not provided");
|
|
245
267
|
return;
|
|
246
268
|
}
|
|
@@ -255,10 +277,10 @@ export const firebaseDataHandler = async data => {
|
|
|
255
277
|
const type = data.type;
|
|
256
278
|
const title = getTitle(type, createdUserName);
|
|
257
279
|
const body = getBody(type, createdUserName);
|
|
258
|
-
|
|
280
|
+
videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Displaying NonRingingPushEvent ${type} notification with title: ${title} body: ${body}`);
|
|
259
281
|
await notifee.displayNotification({
|
|
260
|
-
title,
|
|
261
|
-
body,
|
|
282
|
+
title: getTitle(type, createdUserName),
|
|
283
|
+
body: getBody(type, createdUserName),
|
|
262
284
|
data,
|
|
263
285
|
android: {
|
|
264
286
|
sound: callChannel.sound,
|
|
@@ -282,7 +304,8 @@ export const firebaseDataHandler = async data => {
|
|
|
282
304
|
}
|
|
283
305
|
};
|
|
284
306
|
export const onAndroidNotifeeEvent = async ({
|
|
285
|
-
event
|
|
307
|
+
event,
|
|
308
|
+
isBackground
|
|
286
309
|
}) => {
|
|
287
310
|
if (Platform.OS !== 'android') return;
|
|
288
311
|
const {
|
|
@@ -290,7 +313,8 @@ export const onAndroidNotifeeEvent = async ({
|
|
|
290
313
|
detail
|
|
291
314
|
} = event;
|
|
292
315
|
const {
|
|
293
|
-
notification
|
|
316
|
+
notification,
|
|
317
|
+
pressAction
|
|
294
318
|
} = detail;
|
|
295
319
|
const notificationId = notification?.id;
|
|
296
320
|
const data = notification?.data;
|
|
@@ -301,10 +325,53 @@ export const onAndroidNotifeeEvent = async ({
|
|
|
301
325
|
|
|
302
326
|
// we can safely cast to string because the data is from "stream.video"
|
|
303
327
|
const call_cid = data.call_cid;
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
328
|
+
if (data.type === 'call.ring') {
|
|
329
|
+
// check if we have observers for the call cid (this means the app is in the foreground state)
|
|
330
|
+
const hasObservers = pushAcceptedIncomingCallCId$.observed && pushRejectedIncomingCallCId$.observed;
|
|
331
|
+
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
|
|
332
|
+
const notifee = notifeeLib.default;
|
|
333
|
+
// Check if we need to decline the call
|
|
334
|
+
const didPressDecline = type === notifeeLib.EventType.ACTION_PRESS && pressAction?.id === DECLINE_CALL_ACTION_ID;
|
|
335
|
+
const didDismiss = type === notifeeLib.EventType.DISMISSED;
|
|
336
|
+
const mustDecline = didPressDecline || didDismiss;
|
|
337
|
+
// Check if we need to accept the call
|
|
338
|
+
const mustAccept = type === notifeeLib.EventType.ACTION_PRESS && pressAction?.id === ACCEPT_CALL_ACTION_ID;
|
|
339
|
+
if (mustAccept || mustDecline || type === notifeeLib.EventType.ACTION_PRESS) {
|
|
340
|
+
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`clearPushWSEventSubscriptions for callCId: ${call_cid} mustAccept: ${mustAccept} mustDecline: ${mustDecline}`);
|
|
341
|
+
clearPushWSEventSubscriptions(call_cid);
|
|
342
|
+
notifee.stopForegroundService();
|
|
343
|
+
}
|
|
344
|
+
if (mustAccept) {
|
|
345
|
+
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`pushAcceptedIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
346
|
+
pushAcceptedIncomingCallCId$.next(call_cid);
|
|
347
|
+
// NOTE: accept will be handled by the app with rxjs observers as the app will go to foreground always
|
|
348
|
+
} else if (mustDecline) {
|
|
349
|
+
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`pushRejectedIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
350
|
+
pushRejectedIncomingCallCId$.next(call_cid);
|
|
351
|
+
if (hasObservers) {
|
|
352
|
+
// if we had observers we can return here as the observers will handle the call as the app is in the foreground state
|
|
353
|
+
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`Skipped processCallFromPushInBackground for Declining call with callCId: ${call_cid} as the app is in the foreground state`);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`start processCallFromPushInBackground - Declining call with callCId: ${call_cid}`);
|
|
357
|
+
await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
|
|
358
|
+
} else {
|
|
359
|
+
if (type === notifeeLib.EventType.PRESS) {
|
|
360
|
+
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`pushTappedIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
361
|
+
pushTappedIncomingCallCId$.next(call_cid);
|
|
362
|
+
// pressed state will be handled by the app with rxjs observers as the app will go to foreground always
|
|
363
|
+
} else if (isBackground && type === notifeeLib.EventType.DELIVERED) {
|
|
364
|
+
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`pushAndroidBackgroundDeliveredIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
365
|
+
pushAndroidBackgroundDeliveredIncomingCallCId$.next(call_cid);
|
|
366
|
+
// background delivered state will be handled by the app with rxjs observers as processing needs to happen only when app is opened
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
} else {
|
|
370
|
+
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
|
|
371
|
+
if (type === notifeeLib.EventType.PRESS) {
|
|
372
|
+
videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`onTapNonRingingCallNotification with callCId: ${call_cid}`);
|
|
373
|
+
pushConfig.onTapNonRingingCallNotification?.(call_cid, data.type);
|
|
374
|
+
}
|
|
308
375
|
}
|
|
309
376
|
};
|
|
310
377
|
//# sourceMappingURL=android.js.map
|