@stream-io/video-react-native-sdk 1.29.1-beta.0 → 1.29.2
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 +3133 -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/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/internal/registerSDKGlobals.js +3 -52
- package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/commonjs/utils/push/android.js +202 -155
- 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/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/internal/registerSDKGlobals.js +3 -52
- package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/module/utils/push/android.js +204 -157
- 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/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/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/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 +19 -14
- 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/internal/registerSDKGlobals.ts +4 -47
- package/src/utils/push/android.ts +309 -231
- 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/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/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/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 -13
- 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/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
|
@@ -6,11 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.StreamVideoRN = void 0;
|
|
7
7
|
var _pushLogoutCallback = _interopRequireDefault(require("../internal/pushLogoutCallback"));
|
|
8
8
|
var _newNotificationCallbacks = _interopRequireDefault(require("../internal/newNotificationCallbacks"));
|
|
9
|
+
var _setupIosCallKeepEvents = require("../push/setupIosCallKeepEvents");
|
|
9
10
|
var _setupIosVoipPushEvents = require("../push/setupIosVoipPushEvents");
|
|
10
|
-
var _setupCallingExpEvents = require("../push/setupCallingExpEvents");
|
|
11
|
-
var _callingx = require("../push/libs/callingx");
|
|
12
11
|
var _reactNative = require("react-native");
|
|
13
|
-
var _videoClient = require("@stream-io/video-client");
|
|
14
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
13
|
// Utility type for deep partial
|
|
16
14
|
|
|
@@ -35,7 +33,10 @@ const DEFAULT_STREAM_VIDEO_CONFIG = {
|
|
|
35
33
|
android: {
|
|
36
34
|
channel: {
|
|
37
35
|
id: 'stream_call_foreground_service',
|
|
38
|
-
name: '
|
|
36
|
+
name: 'To keep calls alive',
|
|
37
|
+
lights: false,
|
|
38
|
+
vibration: false,
|
|
39
|
+
importance: 3
|
|
39
40
|
},
|
|
40
41
|
notificationTexts: {
|
|
41
42
|
title: 'Call in progress',
|
|
@@ -57,6 +58,15 @@ class StreamVideoRN {
|
|
|
57
58
|
static updateConfig(updateConfig) {
|
|
58
59
|
this.config = deepMerge(this.config, updateConfig);
|
|
59
60
|
}
|
|
61
|
+
static updateAndroidIncomingCallChannel(updateChannel) {
|
|
62
|
+
const prevChannel = this.config.push?.android?.incomingCallChannel;
|
|
63
|
+
if (prevChannel) {
|
|
64
|
+
this.config.push.android.incomingCallChannel = {
|
|
65
|
+
...prevChannel,
|
|
66
|
+
...updateChannel
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
60
70
|
|
|
61
71
|
/**
|
|
62
72
|
* Set the push config for StreamVideoRN.
|
|
@@ -70,26 +80,7 @@ class StreamVideoRN {
|
|
|
70
80
|
* import App from './App';
|
|
71
81
|
* // Set push config
|
|
72
82
|
* const pushConfig = {}; // construct your config
|
|
73
|
-
*
|
|
74
|
-
* const callingExpOptions = {
|
|
75
|
-
* ios: {
|
|
76
|
-
* callsHistory: true,
|
|
77
|
-
* displayCallTimeout: 60000,
|
|
78
|
-
* sound: 'ringtone',
|
|
79
|
-
* imageName: 'callkit_icon',
|
|
80
|
-
* },
|
|
81
|
-
* android: {
|
|
82
|
-
* incomingChannel: {
|
|
83
|
-
* id: 'stream_incoming_call_notifications',
|
|
84
|
-
* name: 'Call notifications',
|
|
85
|
-
* vibration: true,
|
|
86
|
-
* sound: 'default',
|
|
87
|
-
* },
|
|
88
|
-
* titleTransformer: (text: string) => text,
|
|
89
|
-
* subtitleTransformer: (text: string) => text,
|
|
90
|
-
* },
|
|
91
|
-
* };
|
|
92
|
-
* StreamVideoRN.setPushConfig(pushConfig, callingExpOptions);
|
|
83
|
+
* StreamVideoRN.setPushConfig(pushConfig);
|
|
93
84
|
* AppRegistry.registerComponent('app', () => App);
|
|
94
85
|
*/
|
|
95
86
|
static setPushConfig(pushConfig) {
|
|
@@ -97,16 +88,13 @@ class StreamVideoRN {
|
|
|
97
88
|
// Ignoring this config as push config was already set
|
|
98
89
|
return;
|
|
99
90
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const options = (0, _callingx.extractCallingExpOptions)(this.config);
|
|
105
|
-
callingx.setup(options);
|
|
106
|
-
} catch {
|
|
107
|
-
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/.');
|
|
91
|
+
if (__DEV__ && (pushConfig.navigateAcceptCall || pushConfig.navigateToIncomingCall)) {
|
|
92
|
+
throw new Error(`Support for navigateAcceptCall or navigateToIncomingCall in pushConfig has been removed.
|
|
93
|
+
Please watch for incoming and outgoing calls in the root component of your app.
|
|
94
|
+
Please see https://getstream.io/video/docs/react-native/advanced/ringing-calls/#watch-for-incoming-and-outgoing-calls for more information.`);
|
|
108
95
|
}
|
|
109
|
-
|
|
96
|
+
this.config.push = pushConfig;
|
|
97
|
+
(0, _setupIosCallKeepEvents.setupIosCallKeepEvents)(pushConfig);
|
|
110
98
|
(0, _setupIosVoipPushEvents.setupIosVoipPushEvents)(pushConfig);
|
|
111
99
|
}
|
|
112
100
|
static getConfig() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_pushLogoutCallback","_interopRequireDefault","require","_newNotificationCallbacks","
|
|
1
|
+
{"version":3,"names":["_pushLogoutCallback","_interopRequireDefault","require","_newNotificationCallbacks","_setupIosCallKeepEvents","_setupIosVoipPushEvents","_reactNative","e","__esModule","default","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","setupIosCallKeepEvents","setupIosVoipPushEvents","getConfig","onPushLogout","pushLogoutCallbacks","current","all","map","callback","then","resolve","clearPushLogoutCallbacks","addOnNewCallNotificationListener","newNotificationCallbacks","filter","cb","playBusyTone","NativeModules","StreamVideoReactNative","stopBusyTone","androidHasAudioOutputHardware","Platform","OS","hasAudioOutputHardware","androidHasMicrophoneHardware","hasMicrophoneHardware","androidHasCameraHardware","hasCameraHardware","exports"],"sourceRoot":"../../../../src","sources":["utils/StreamVideoRN/index.ts"],"mappings":";;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,yBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA,IAAAE,uBAAA,GAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAAuD,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEvD;;AAKA;AACA,SAASG,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,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,CAAC,CAAC;EACjE;AACF;AAACC,OAAA,CAAA3C,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -5,69 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.registerSDKGlobals = registerSDKGlobals;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
|
-
var _callingx = require("../push/libs/callingx");
|
|
9
|
-
var _callingx2 = require("./callingx/callingx");
|
|
10
8
|
const StreamInCallManagerNativeModule = _reactNative.NativeModules.StreamInCallManager;
|
|
11
9
|
const StreamVideoReactNativeModule = _reactNative.NativeModules.StreamVideoReactNative;
|
|
12
|
-
const CallingxModule = (0, _callingx.getCallingxLibIfAvailable)();
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Checks if StreamInCallManager should be bypassed because CallKit is handling
|
|
16
|
-
* the audio session via CallingX.
|
|
17
|
-
*
|
|
18
|
-
* On iOS, when CallingX is set up and has a registered call, the audio session
|
|
19
|
-
* is managed by CallKit through CallingxImpl.swift.
|
|
20
|
-
* In this case, StreamInCallManager should not run to avoid conflicting audio
|
|
21
|
-
* session configurations.
|
|
22
|
-
*/
|
|
23
|
-
const shouldBypassForCallKit = ({
|
|
24
|
-
isRingingTypeCall
|
|
25
|
-
}) => {
|
|
26
|
-
if (_reactNative.Platform.OS !== 'ios') {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
if (!CallingxModule) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
const bypass = CallingxModule.isSetup && (isRingingTypeCall || CallingxModule.isOngoingCallsEnabled);
|
|
33
|
-
return bypass;
|
|
34
|
-
};
|
|
35
10
|
const streamRNVideoSDKGlobals = {
|
|
36
|
-
callingX: {
|
|
37
|
-
startCall: _callingx2.startCallingxCall,
|
|
38
|
-
endCall: _callingx2.endCallingxCall
|
|
39
|
-
},
|
|
40
11
|
callManager: {
|
|
41
12
|
setup: ({
|
|
42
|
-
defaultDevice
|
|
43
|
-
isRingingTypeCall
|
|
13
|
+
defaultDevice
|
|
44
14
|
}) => {
|
|
45
|
-
if (shouldBypassForCallKit({
|
|
46
|
-
isRingingTypeCall
|
|
47
|
-
})) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
15
|
StreamInCallManagerNativeModule.setDefaultAudioDeviceEndpointType(defaultDevice);
|
|
51
16
|
StreamInCallManagerNativeModule.setup();
|
|
52
17
|
},
|
|
53
|
-
start: ({
|
|
54
|
-
isRingingTypeCall
|
|
55
|
-
}) => {
|
|
56
|
-
if (shouldBypassForCallKit({
|
|
57
|
-
isRingingTypeCall
|
|
58
|
-
})) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
18
|
+
start: () => {
|
|
61
19
|
StreamInCallManagerNativeModule.start();
|
|
62
20
|
},
|
|
63
|
-
stop: ({
|
|
64
|
-
isRingingTypeCall
|
|
65
|
-
}) => {
|
|
66
|
-
if (shouldBypassForCallKit({
|
|
67
|
-
isRingingTypeCall
|
|
68
|
-
})) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
21
|
+
stop: () => {
|
|
71
22
|
StreamInCallManagerNativeModule.stop();
|
|
72
23
|
}
|
|
73
24
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","StreamInCallManagerNativeModule","NativeModules","StreamInCallManager","StreamVideoReactNativeModule","StreamVideoReactNative","streamRNVideoSDKGlobals","callManager","setup","defaultDevice","setDefaultAudioDeviceEndpointType","start","stop","permissions","check","permission","Platform","OS","nativeAndroidPermission","PermissionsAndroid","PERMISSIONS","CAMERA","RECORD_AUDIO","Boolean","checkPermission","registerSDKGlobals","global","streamRNVideoSDK"],"sourceRoot":"../../../../src","sources":["utils/internal/registerSDKGlobals.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,+BAA+B,GAAGC,0BAAa,CAACC,mBAAmB;AACzE,MAAMC,4BAA4B,GAAGF,0BAAa,CAACG,sBAElD;AAED,MAAMC,uBAAgD,GAAG;EACvDC,WAAW,EAAE;IACXC,KAAK,EAAEA,CAAC;MAAEC;IAAc,CAAC,KAAK;MAC5BR,+BAA+B,CAACS,iCAAiC,CAC/DD,aACF,CAAC;MACDR,+BAA+B,CAACO,KAAK,CAAC,CAAC;IACzC,CAAC;IACDG,KAAK,EAAEA,CAAA,KAAM;MACXV,+BAA+B,CAACU,KAAK,CAAC,CAAC;IACzC,CAAC;IACDC,IAAI,EAAEA,CAAA,KAAM;MACVX,+BAA+B,CAACW,IAAI,CAAC,CAAC;IACxC;EACF,CAAC;EACDC,WAAW,EAAE;IACXC,KAAK,EAAE,MAAOC,UAAU,IAAK;MAC3B,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;QAC7B,MAAMC,uBAAuB,GAC3BH,UAAU,KAAK,QAAQ,GACnBI,+BAAkB,CAACC,WAAW,CAACC,MAAM,GACrCF,+BAAkB,CAACC,WAAW,CAACE,YAAY;QACjD,OAAOH,+BAAkB,CAACL,KAAK,CAACI,uBAAuB,CAAC;MAC1D;;MAEA;MACA,OAAOK,OAAO,CACZ,MAAMnB,4BAA4B,CAACoB,eAAe,GAAGT,UAAU,CACjE,CAAC;IACH;EACF;AACF,CAAC;;AAED;AACA;AACA;AACO,SAASU,kBAAkBA,CAAA,EAAG;EACnC,IAAI,CAACC,MAAM,CAACC,gBAAgB,EAAE;IAC5BD,MAAM,CAACC,gBAAgB,GAAGrB,uBAAuB;EACnD;AACF","ignoreList":[]}
|
|
@@ -13,8 +13,10 @@ var _rxSubjects = require("./internal/rxSubjects");
|
|
|
13
13
|
var _constants = require("./internal/constants");
|
|
14
14
|
var _utils = require("./internal/utils");
|
|
15
15
|
var _pushLogoutCallback = require("../internal/pushLogoutCallback");
|
|
16
|
+
var _getAndroidDefaultRingtoneUrl = require("../getAndroidDefaultRingtoneUrl");
|
|
16
17
|
var _StreamVideoRN = require("../StreamVideoRN");
|
|
17
|
-
|
|
18
|
+
const ACCEPT_CALL_ACTION_ID = 'accept';
|
|
19
|
+
const DECLINE_CALL_ACTION_ID = 'decline';
|
|
18
20
|
let lastFirebaseToken = {
|
|
19
21
|
token: '',
|
|
20
22
|
userId: ''
|
|
@@ -69,7 +71,8 @@ async function initAndroidPushToken(client, pushConfig, setUnsubscribeListener)
|
|
|
69
71
|
await setDeviceToken(token);
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
|
-
|
|
74
|
+
// TODO: remove the incomingCallChannel check and find a better way once we have telecom integration for android
|
|
75
|
+
const messaging = pushConfig.isExpo && !pushConfig.android.incomingCallChannel ? (0, _libs.getFirebaseMessagingLibNoThrow)(true) : (0, _libs.getFirebaseMessagingLib)();
|
|
73
76
|
if (messaging) {
|
|
74
77
|
logger.debug(`setting firebase token listeners`);
|
|
75
78
|
const unsubscribe = messaging().onTokenRefresh(refreshedToken => setDeviceToken(refreshedToken));
|
|
@@ -83,8 +86,8 @@ async function initAndroidPushToken(client, pushConfig, setUnsubscribeListener)
|
|
|
83
86
|
* Creates notification from the push message data.
|
|
84
87
|
* For Ringing and Non-Ringing calls.
|
|
85
88
|
*/
|
|
86
|
-
|
|
87
89
|
const firebaseDataHandler = async data => {
|
|
90
|
+
if (_reactNative.Platform.OS !== 'android') return;
|
|
88
91
|
/* Example data from firebase
|
|
89
92
|
"message": {
|
|
90
93
|
"data": {
|
|
@@ -100,175 +103,174 @@ const firebaseDataHandler = async data => {
|
|
|
100
103
|
// other stuff
|
|
101
104
|
}
|
|
102
105
|
*/
|
|
103
|
-
if (_reactNative.Platform.OS !== 'android') return;
|
|
104
|
-
const logger = _videoClient.videoLoggerSystem.getLogger('firebaseDataHandler');
|
|
105
106
|
const pushConfig = _StreamVideoRN.StreamVideoRN.getConfig().push;
|
|
106
107
|
if (!pushConfig || !data || data.sender !== 'stream.video') {
|
|
107
108
|
return;
|
|
108
109
|
}
|
|
110
|
+
const notifeeLib = (0, _libs.getNotifeeLibThrowIfNotInstalledForPush)();
|
|
111
|
+
const notifee = notifeeLib.default;
|
|
112
|
+
const settings = await notifee.getNotificationSettings();
|
|
113
|
+
if (settings.authorizationStatus !== 1) {
|
|
114
|
+
const logger = _videoClient.videoLoggerSystem.getLogger('firebaseDataHandler');
|
|
115
|
+
logger.debug(`Notification permission not granted, unable to post ${data.type} notifications`);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
109
118
|
if (data.type === 'call.ring') {
|
|
110
119
|
const call_cid = data.call_cid;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const shouldRejectCallWhenBusy = client['rejectCallWhenBusy'] ?? false;
|
|
126
|
-
if (callingx.hasRegisteredCall() && shouldRejectCallWhenBusy) {
|
|
127
|
-
logger.debug(`registered call found, skipping the call.ring notification`);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
const asForegroundService = (0, _utils.canListenToWS)();
|
|
131
|
-
const callerName = data.created_by_display_name;
|
|
132
|
-
const hasVideo = data.video === 'true';
|
|
120
|
+
const created_by_id = data.created_by_id;
|
|
121
|
+
const receiver_id = data.receiver_id;
|
|
122
|
+
const video_client = await pushConfig.createStreamVideoClient();
|
|
123
|
+
await video_client?.onRingingCall(call_cid);
|
|
124
|
+
const shouldCallBeClosed = callToCheck => {
|
|
125
|
+
const {
|
|
126
|
+
mustEndCall
|
|
127
|
+
} = (0, _utils.shouldCallBeEnded)(callToCheck, created_by_id, receiver_id);
|
|
128
|
+
return mustEndCall;
|
|
129
|
+
};
|
|
130
|
+
const canListenToWS = () => _utils.canAddPushWSSubscriptionsRef.current && _reactNative.AppState.currentState !== 'active';
|
|
131
|
+
const asForegroundService = canListenToWS();
|
|
133
132
|
if (asForegroundService) {
|
|
134
133
|
// Listen to call events from WS through fg service
|
|
135
134
|
// note: this will replace the current empty fg service runner
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
logger.debug(`Closing fg service callCid: ${call_cid} endCallReason: ${endCallReason}`);
|
|
159
|
-
finishBackgroundTask();
|
|
160
|
-
callingx.log(`Ending call with callCid: ${call_cid} endCallReason: ${endCallReason}`, 'debug');
|
|
161
|
-
callingx.endCallWithReason(call_cid, endCallReason);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const unsubscribeFunctions = [];
|
|
165
|
-
// check if service needs to be closed if accept/decline event was done on another device
|
|
166
|
-
const unsubscribe = callFromPush.on('all', event => {
|
|
167
|
-
const _canListenToWS = (0, _utils.canListenToWS)();
|
|
168
|
-
if (!_canListenToWS) {
|
|
169
|
-
logger.debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, {
|
|
170
|
-
event
|
|
171
|
-
});
|
|
172
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
173
|
-
finishBackgroundTask();
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const {
|
|
177
|
-
mustEndCall: mustEndCallFromEvent,
|
|
178
|
-
endCallReason: endCallReasonFromEvent
|
|
179
|
-
} = (0, _utils.shouldCallBeClosed)(callFromPush, data);
|
|
180
|
-
if (mustEndCallFromEvent) {
|
|
181
|
-
logger.debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS} shouldCallBeClosed`, {
|
|
182
|
-
event
|
|
183
|
-
});
|
|
184
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
185
|
-
finishBackgroundTask();
|
|
186
|
-
callingx.endCallWithReason(call_cid, endCallReasonFromEvent);
|
|
187
|
-
}
|
|
135
|
+
notifee.registerForegroundService(() => {
|
|
136
|
+
return new Promise(async () => {
|
|
137
|
+
const client = await pushConfig.createStreamVideoClient();
|
|
138
|
+
if (!client) {
|
|
139
|
+
_videoClient.videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Closing fg service as there is no client to create from push config`);
|
|
140
|
+
notifee.stopForegroundService();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const callFromPush = await client.onRingingCall(call_cid);
|
|
144
|
+
let _shouldCallBeClosed = shouldCallBeClosed(callFromPush);
|
|
145
|
+
if (_shouldCallBeClosed) {
|
|
146
|
+
_videoClient.videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Closing fg service callCid: ${call_cid} shouldCallBeClosed: ${_shouldCallBeClosed}`);
|
|
147
|
+
notifee.stopForegroundService();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const unsubscribeFunctions = [];
|
|
151
|
+
// check if service needs to be closed if accept/decline event was done on another device
|
|
152
|
+
const unsubscribe = callFromPush.on('all', event => {
|
|
153
|
+
const _canListenToWS = canListenToWS();
|
|
154
|
+
if (!_canListenToWS) {
|
|
155
|
+
_videoClient.videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, {
|
|
156
|
+
event
|
|
188
157
|
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
callingx.log(`Ending call with callCid: ${call_cid} callingState: ${callingState}`, 'debug');
|
|
198
|
-
finishBackgroundTask();
|
|
199
|
-
callingx.endCallWithReason(call_cid, 'remote');
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
const endCallSubscription = callingx.addEventListener('endCall', async ({
|
|
203
|
-
callId
|
|
204
|
-
}) => {
|
|
205
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
206
|
-
try {
|
|
207
|
-
await callFromPush.leave({
|
|
208
|
-
reject: true,
|
|
209
|
-
reason: 'decline'
|
|
210
|
-
});
|
|
211
|
-
} catch (error) {
|
|
212
|
-
logger.error(`Failed to leave call with callCid: ${call_cid} error: ${error}`);
|
|
213
|
-
} finally {
|
|
214
|
-
callingx.log(`Ending call with callCid: ${call_cid} callId: ${callId}`, 'debug');
|
|
215
|
-
finishBackgroundTask();
|
|
216
|
-
callingx.endCallWithReason(callId, 'rejected');
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
//stop background task when app comes to foreground
|
|
221
|
-
const appStateSubscription = _reactNative.AppState.addEventListener('change', nextAppState => {
|
|
222
|
-
const _canListenToWS = (0, _utils.canListenToWS)();
|
|
223
|
-
callingx.log(`AppState changed to: ${nextAppState} for callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, 'debug');
|
|
224
|
-
if (!_canListenToWS) {
|
|
225
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
226
|
-
finishBackgroundTask();
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
158
|
+
unsubscribeFunctions.forEach(fn => fn());
|
|
159
|
+
notifee.stopForegroundService();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
_shouldCallBeClosed = shouldCallBeClosed(callFromPush);
|
|
163
|
+
if (_shouldCallBeClosed) {
|
|
164
|
+
_videoClient.videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS} shouldCallBeClosed: ${_shouldCallBeClosed}`, {
|
|
165
|
+
event
|
|
229
166
|
});
|
|
230
|
-
unsubscribeFunctions.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
167
|
+
unsubscribeFunctions.forEach(fn => fn());
|
|
168
|
+
notifee.stopForegroundService();
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
// check if service needs to be closed if call was left
|
|
172
|
+
const subscription = callFromPush.state.callingState$.subscribe(callingState => {
|
|
173
|
+
if (callingState === _videoClient.CallingState.IDLE || callingState === _videoClient.CallingState.LEFT) {
|
|
174
|
+
_videoClient.videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Closing fg service from callingState callCid: ${call_cid} callingState: ${callingState}`);
|
|
175
|
+
unsubscribeFunctions.forEach(fn => fn());
|
|
176
|
+
notifee.stopForegroundService();
|
|
239
177
|
}
|
|
240
|
-
})
|
|
178
|
+
});
|
|
179
|
+
unsubscribeFunctions.push(unsubscribe);
|
|
180
|
+
unsubscribeFunctions.push(() => subscription.unsubscribe());
|
|
181
|
+
_constants.pushUnsubscriptionCallbacks.get(call_cid)?.forEach(cb => cb());
|
|
182
|
+
_constants.pushUnsubscriptionCallbacks.set(call_cid, unsubscribeFunctions);
|
|
241
183
|
});
|
|
242
184
|
});
|
|
243
185
|
}
|
|
244
|
-
|
|
245
|
-
|
|
186
|
+
const incomingCallChannel = pushConfig.android.incomingCallChannel;
|
|
187
|
+
const incomingCallNotificationTextGetters = pushConfig.android.incomingCallNotificationTextGetters;
|
|
188
|
+
if (!incomingCallChannel || !incomingCallNotificationTextGetters) {
|
|
189
|
+
const logger = _videoClient.videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler');
|
|
190
|
+
logger.error("Can't show incoming call notification as either or both incomingCallChannel and incomingCallNotificationTextGetters were not provided");
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
/*
|
|
194
|
+
* Sound has to be set on channel level for android 8 and above and cant be updated later after creation!
|
|
195
|
+
* For android 7 and below, sound should be set on notification level
|
|
196
|
+
*/
|
|
197
|
+
// set default ringtone if not provided
|
|
198
|
+
if (!incomingCallChannel.sound) {
|
|
199
|
+
incomingCallChannel.sound = await (0, _getAndroidDefaultRingtoneUrl.getAndroidDefaultRingtoneUrl)();
|
|
200
|
+
}
|
|
201
|
+
await notifee.createChannel(incomingCallChannel);
|
|
202
|
+
const {
|
|
203
|
+
getTitle,
|
|
204
|
+
getBody,
|
|
205
|
+
getAcceptButtonTitle,
|
|
206
|
+
getDeclineButtonTitle
|
|
207
|
+
} = incomingCallNotificationTextGetters;
|
|
208
|
+
const createdUserName = data.created_by_display_name;
|
|
209
|
+
const title = getTitle(createdUserName);
|
|
210
|
+
const body = getBody(createdUserName);
|
|
211
|
+
_videoClient.videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Displaying incoming call notification with callCid: ${call_cid} title: ${title} body: ${body} asForegroundService: ${asForegroundService}`);
|
|
212
|
+
const channelId = incomingCallChannel.id;
|
|
213
|
+
await notifee.displayNotification({
|
|
214
|
+
id: call_cid,
|
|
215
|
+
title: getTitle(createdUserName),
|
|
216
|
+
body: getBody(createdUserName),
|
|
217
|
+
data,
|
|
218
|
+
android: {
|
|
219
|
+
channelId,
|
|
220
|
+
smallIcon: pushConfig.android.smallIcon,
|
|
221
|
+
importance: 4,
|
|
222
|
+
// high importance
|
|
223
|
+
foregroundServiceTypes: (0, _libs.getIncomingCallForegroundServiceTypes)(),
|
|
224
|
+
asForegroundService,
|
|
225
|
+
ongoing: true,
|
|
226
|
+
sound: incomingCallChannel.sound,
|
|
227
|
+
vibrationPattern: incomingCallChannel.vibrationPattern,
|
|
228
|
+
loopSound: true,
|
|
229
|
+
pressAction: {
|
|
230
|
+
id: 'default',
|
|
231
|
+
launchActivity: 'default' // open the app when the notification is pressed
|
|
232
|
+
},
|
|
233
|
+
actions: [{
|
|
234
|
+
title: getDeclineButtonTitle?.() ?? 'Decline',
|
|
235
|
+
pressAction: {
|
|
236
|
+
id: DECLINE_CALL_ACTION_ID
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
title: getAcceptButtonTitle?.() ?? 'Accept',
|
|
240
|
+
pressAction: {
|
|
241
|
+
id: ACCEPT_CALL_ACTION_ID,
|
|
242
|
+
launchActivity: 'default' // open the app when the notification is pressed
|
|
243
|
+
}
|
|
244
|
+
}],
|
|
245
|
+
category: notifeeLib.AndroidCategory.CALL,
|
|
246
|
+
fullScreenAction: {
|
|
247
|
+
id: 'stream_ringing_incoming_call'
|
|
248
|
+
},
|
|
249
|
+
timeoutAfter: 60000 // 60 seconds, after which the notification will be dismissed automatically
|
|
250
|
+
}
|
|
251
|
+
});
|
|
246
252
|
if (asForegroundService) {
|
|
247
253
|
// no need to check if call has be closed as that will be handled by the fg service
|
|
248
254
|
return;
|
|
249
255
|
}
|
|
256
|
+
|
|
257
|
+
// check if call needs to be closed if accept/decline event was done
|
|
258
|
+
// before the notification was shown
|
|
259
|
+
const client = await pushConfig.createStreamVideoClient();
|
|
260
|
+
if (!client) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
250
263
|
const callFromPush = await client.onRingingCall(call_cid);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
} = (0, _utils.shouldCallBeClosed)(callFromPush, data);
|
|
255
|
-
if (mustEndCall) {
|
|
256
|
-
logger.debug(`Removing incoming call notification immediately with callCid: ${call_cid} as it should be closed`);
|
|
257
|
-
callingx.endCallWithReason(call_cid, endCallReason);
|
|
264
|
+
if (shouldCallBeClosed(callFromPush)) {
|
|
265
|
+
_videoClient.videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Removing incoming call notification immediately with callCid: ${call_cid} as it should be closed`);
|
|
266
|
+
notifee.cancelDisplayedNotification(call_cid);
|
|
258
267
|
}
|
|
259
268
|
} else {
|
|
260
|
-
const notifeeLib = (0, _libs.getNotifeeLibThrowIfNotInstalledForPush)();
|
|
261
|
-
const notifee = notifeeLib.default;
|
|
262
|
-
const settings = await notifee.getNotificationSettings();
|
|
263
|
-
if (settings.authorizationStatus !== 1) {
|
|
264
|
-
logger.debug(`Notification permission not granted, unable to post ${data.type} notifications`);
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
269
|
// the other types are call.live_started and call.notification
|
|
269
270
|
const callChannel = pushConfig.android.callChannel;
|
|
270
271
|
const callNotificationTextGetters = pushConfig.android.callNotificationTextGetters;
|
|
271
272
|
if (!callChannel || !callNotificationTextGetters) {
|
|
273
|
+
const logger = _videoClient.videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler');
|
|
272
274
|
logger.debug("Can't show call notification as either or both callChannel and callNotificationTextGetters is not provided");
|
|
273
275
|
return;
|
|
274
276
|
}
|
|
@@ -283,10 +285,10 @@ const firebaseDataHandler = async data => {
|
|
|
283
285
|
const type = data.type;
|
|
284
286
|
const title = getTitle(type, createdUserName);
|
|
285
287
|
const body = getBody(type, createdUserName);
|
|
286
|
-
|
|
288
|
+
_videoClient.videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Displaying NonRingingPushEvent ${type} notification with title: ${title} body: ${body}`);
|
|
287
289
|
await notifee.displayNotification({
|
|
288
|
-
title,
|
|
289
|
-
body,
|
|
290
|
+
title: getTitle(type, createdUserName),
|
|
291
|
+
body: getBody(type, createdUserName),
|
|
290
292
|
data,
|
|
291
293
|
android: {
|
|
292
294
|
sound: callChannel.sound,
|
|
@@ -311,7 +313,8 @@ const firebaseDataHandler = async data => {
|
|
|
311
313
|
};
|
|
312
314
|
exports.firebaseDataHandler = firebaseDataHandler;
|
|
313
315
|
const onAndroidNotifeeEvent = async ({
|
|
314
|
-
event
|
|
316
|
+
event,
|
|
317
|
+
isBackground
|
|
315
318
|
}) => {
|
|
316
319
|
if (_reactNative.Platform.OS !== 'android') return;
|
|
317
320
|
const {
|
|
@@ -319,7 +322,8 @@ const onAndroidNotifeeEvent = async ({
|
|
|
319
322
|
detail
|
|
320
323
|
} = event;
|
|
321
324
|
const {
|
|
322
|
-
notification
|
|
325
|
+
notification,
|
|
326
|
+
pressAction
|
|
323
327
|
} = detail;
|
|
324
328
|
const notificationId = notification?.id;
|
|
325
329
|
const data = notification?.data;
|
|
@@ -330,10 +334,53 @@ const onAndroidNotifeeEvent = async ({
|
|
|
330
334
|
|
|
331
335
|
// we can safely cast to string because the data is from "stream.video"
|
|
332
336
|
const call_cid = data.call_cid;
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
+
if (data.type === 'call.ring') {
|
|
338
|
+
// check if we have observers for the call cid (this means the app is in the foreground state)
|
|
339
|
+
const hasObservers = _rxSubjects.pushAcceptedIncomingCallCId$.observed && _rxSubjects.pushRejectedIncomingCallCId$.observed;
|
|
340
|
+
const notifeeLib = (0, _libs.getNotifeeLibThrowIfNotInstalledForPush)();
|
|
341
|
+
const notifee = notifeeLib.default;
|
|
342
|
+
// Check if we need to decline the call
|
|
343
|
+
const didPressDecline = type === notifeeLib.EventType.ACTION_PRESS && pressAction?.id === DECLINE_CALL_ACTION_ID;
|
|
344
|
+
const didDismiss = type === notifeeLib.EventType.DISMISSED;
|
|
345
|
+
const mustDecline = didPressDecline || didDismiss;
|
|
346
|
+
// Check if we need to accept the call
|
|
347
|
+
const mustAccept = type === notifeeLib.EventType.ACTION_PRESS && pressAction?.id === ACCEPT_CALL_ACTION_ID;
|
|
348
|
+
if (mustAccept || mustDecline || type === notifeeLib.EventType.ACTION_PRESS) {
|
|
349
|
+
_videoClient.videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`clearPushWSEventSubscriptions for callCId: ${call_cid} mustAccept: ${mustAccept} mustDecline: ${mustDecline}`);
|
|
350
|
+
(0, _utils.clearPushWSEventSubscriptions)(call_cid);
|
|
351
|
+
notifee.stopForegroundService();
|
|
352
|
+
}
|
|
353
|
+
if (mustAccept) {
|
|
354
|
+
_videoClient.videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`pushAcceptedIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
355
|
+
_rxSubjects.pushAcceptedIncomingCallCId$.next(call_cid);
|
|
356
|
+
// NOTE: accept will be handled by the app with rxjs observers as the app will go to foreground always
|
|
357
|
+
} else if (mustDecline) {
|
|
358
|
+
_videoClient.videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`pushRejectedIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
359
|
+
_rxSubjects.pushRejectedIncomingCallCId$.next(call_cid);
|
|
360
|
+
if (hasObservers) {
|
|
361
|
+
// if we had observers we can return here as the observers will handle the call as the app is in the foreground state
|
|
362
|
+
_videoClient.videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`Skipped processCallFromPushInBackground for Declining call with callCId: ${call_cid} as the app is in the foreground state`);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
_videoClient.videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`start processCallFromPushInBackground - Declining call with callCId: ${call_cid}`);
|
|
366
|
+
await (0, _utils.processCallFromPushInBackground)(pushConfig, call_cid, 'decline');
|
|
367
|
+
} else {
|
|
368
|
+
if (type === notifeeLib.EventType.PRESS) {
|
|
369
|
+
_videoClient.videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`pushTappedIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
370
|
+
_rxSubjects.pushTappedIncomingCallCId$.next(call_cid);
|
|
371
|
+
// pressed state will be handled by the app with rxjs observers as the app will go to foreground always
|
|
372
|
+
} else if (isBackground && type === notifeeLib.EventType.DELIVERED) {
|
|
373
|
+
_videoClient.videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`pushAndroidBackgroundDeliveredIncomingCallCId$ added with callCId: ${call_cid}`);
|
|
374
|
+
_rxSubjects.pushAndroidBackgroundDeliveredIncomingCallCId$.next(call_cid);
|
|
375
|
+
// background delivered state will be handled by the app with rxjs observers as processing needs to happen only when app is opened
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
const notifeeLib = (0, _libs.getNotifeeLibThrowIfNotInstalledForPush)();
|
|
380
|
+
if (type === notifeeLib.EventType.PRESS) {
|
|
381
|
+
_videoClient.videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`onTapNonRingingCallNotification with callCId: ${call_cid}`);
|
|
382
|
+
pushConfig.onTapNonRingingCallNotification?.(call_cid, data.type);
|
|
383
|
+
}
|
|
337
384
|
}
|
|
338
385
|
};
|
|
339
386
|
exports.onAndroidNotifeeEvent = onAndroidNotifeeEvent;
|