@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.
Files changed (211) hide show
  1. package/CHANGELOG.md +3133 -0
  2. package/android/src/main/AndroidManifest.xml +1 -8
  3. package/android/src/main/AndroidManifestNew.xml +0 -11
  4. package/android/src/main/java/com/streamvideo/reactnative/StreamVideoReactNativeModule.kt +5 -42
  5. package/android/src/main/java/com/streamvideo/reactnative/audio/utils/WebRtcAudioUtils.kt +6 -70
  6. package/android/src/main/java/com/streamvideo/reactnative/callmanager/StreamInCallManagerModule.kt +4 -6
  7. package/android/src/main/java/com/streamvideo/reactnative/util/CallAliveServiceChecker.kt +95 -0
  8. package/dist/commonjs/hooks/push/index.js +2 -0
  9. package/dist/commonjs/hooks/push/index.js.map +1 -1
  10. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +160 -0
  11. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
  12. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
  13. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  14. package/dist/commonjs/hooks/push/useProcessPushCallEffect.js +67 -0
  15. package/dist/commonjs/hooks/push/useProcessPushCallEffect.js.map +1 -0
  16. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +97 -64
  17. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  18. package/dist/commonjs/index.js +0 -1
  19. package/dist/commonjs/index.js.map +1 -1
  20. package/dist/commonjs/modules/call-manager/CallManager.js +0 -26
  21. package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
  22. package/dist/commonjs/providers/StreamCall/index.js +6 -6
  23. package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
  24. package/dist/commonjs/utils/StreamVideoRN/index.js +21 -33
  25. package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
  26. package/dist/commonjs/utils/internal/registerSDKGlobals.js +3 -52
  27. package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
  28. package/dist/commonjs/utils/push/android.js +202 -155
  29. package/dist/commonjs/utils/push/android.js.map +1 -1
  30. package/dist/commonjs/utils/push/internal/ios.js +34 -17
  31. package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
  32. package/dist/commonjs/utils/push/internal/rxSubjects.js +45 -1
  33. package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
  34. package/dist/commonjs/utils/push/internal/utils.js +20 -32
  35. package/dist/commonjs/utils/push/internal/utils.js.map +1 -1
  36. package/dist/commonjs/utils/push/ios.js.map +1 -1
  37. package/dist/commonjs/utils/push/libs/callkeep.js +17 -0
  38. package/dist/commonjs/utils/push/libs/callkeep.js.map +1 -0
  39. package/dist/commonjs/utils/push/libs/index.js +19 -8
  40. package/dist/commonjs/utils/push/libs/index.js.map +1 -1
  41. package/dist/commonjs/utils/push/libs/notifee/index.js +19 -0
  42. package/dist/commonjs/utils/push/libs/notifee/index.js.map +1 -1
  43. package/dist/commonjs/utils/push/libs/voipPushNotification.js +17 -0
  44. package/dist/commonjs/utils/push/libs/voipPushNotification.js.map +1 -0
  45. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +205 -0
  46. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +1 -0
  47. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +6 -7
  48. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
  49. package/dist/commonjs/version.js +1 -1
  50. package/dist/commonjs/version.js.map +1 -1
  51. package/dist/module/hooks/push/index.js +2 -0
  52. package/dist/module/hooks/push/index.js.map +1 -1
  53. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +153 -0
  54. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
  55. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
  56. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  57. package/dist/module/hooks/push/useProcessPushCallEffect.js +60 -0
  58. package/dist/module/hooks/push/useProcessPushCallEffect.js.map +1 -0
  59. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +99 -66
  60. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  61. package/dist/module/index.js +0 -1
  62. package/dist/module/index.js.map +1 -1
  63. package/dist/module/modules/call-manager/CallManager.js +0 -26
  64. package/dist/module/modules/call-manager/CallManager.js.map +1 -1
  65. package/dist/module/providers/StreamCall/index.js +6 -6
  66. package/dist/module/providers/StreamCall/index.js.map +1 -1
  67. package/dist/module/utils/StreamVideoRN/index.js +21 -33
  68. package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
  69. package/dist/module/utils/internal/registerSDKGlobals.js +3 -52
  70. package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
  71. package/dist/module/utils/push/android.js +204 -157
  72. package/dist/module/utils/push/android.js.map +1 -1
  73. package/dist/module/utils/push/internal/ios.js +34 -17
  74. package/dist/module/utils/push/internal/ios.js.map +1 -1
  75. package/dist/module/utils/push/internal/rxSubjects.js +44 -0
  76. package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
  77. package/dist/module/utils/push/internal/utils.js +19 -29
  78. package/dist/module/utils/push/internal/utils.js.map +1 -1
  79. package/dist/module/utils/push/ios.js.map +1 -1
  80. package/dist/module/utils/push/libs/callkeep.js +11 -0
  81. package/dist/module/utils/push/libs/callkeep.js.map +1 -0
  82. package/dist/module/utils/push/libs/index.js +2 -1
  83. package/dist/module/utils/push/libs/index.js.map +1 -1
  84. package/dist/module/utils/push/libs/notifee/index.js +18 -0
  85. package/dist/module/utils/push/libs/notifee/index.js.map +1 -1
  86. package/dist/module/utils/push/libs/voipPushNotification.js +11 -0
  87. package/dist/module/utils/push/libs/voipPushNotification.js.map +1 -0
  88. package/dist/module/utils/push/setupIosCallKeepEvents.js +199 -0
  89. package/dist/module/utils/push/setupIosCallKeepEvents.js.map +1 -0
  90. package/dist/module/utils/push/setupIosVoipPushEvents.js +6 -7
  91. package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
  92. package/dist/module/version.js +1 -1
  93. package/dist/module/version.js.map +1 -1
  94. package/dist/typescript/hooks/push/index.d.ts.map +1 -1
  95. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts +5 -0
  96. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +1 -0
  97. package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
  98. package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts +8 -0
  99. package/dist/typescript/hooks/push/useProcessPushCallEffect.d.ts.map +1 -0
  100. package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
  101. package/dist/typescript/index.d.ts +0 -1
  102. package/dist/typescript/index.d.ts.map +1 -1
  103. package/dist/typescript/modules/call-manager/CallManager.d.ts +0 -5
  104. package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
  105. package/dist/typescript/utils/StreamVideoRN/index.d.ts +2 -20
  106. package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
  107. package/dist/typescript/utils/StreamVideoRN/types.d.ts +29 -54
  108. package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
  109. package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
  110. package/dist/typescript/utils/push/android.d.ts +2 -1
  111. package/dist/typescript/utils/push/android.d.ts.map +1 -1
  112. package/dist/typescript/utils/push/internal/ios.d.ts.map +1 -1
  113. package/dist/typescript/utils/push/internal/rxSubjects.d.ts +33 -0
  114. package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
  115. package/dist/typescript/utils/push/internal/utils.d.ts +1 -8
  116. package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
  117. package/dist/typescript/utils/push/ios.d.ts +2 -1
  118. package/dist/typescript/utils/push/ios.d.ts.map +1 -1
  119. package/dist/typescript/utils/push/libs/callkeep.d.ts +3 -0
  120. package/dist/typescript/utils/push/libs/callkeep.d.ts.map +1 -0
  121. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts +2 -16
  122. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
  123. package/dist/typescript/utils/push/libs/index.d.ts +2 -1
  124. package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
  125. package/dist/typescript/utils/push/libs/notifee/index.d.ts +1 -0
  126. package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
  127. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +3 -0
  128. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +1 -0
  129. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +6 -0
  130. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +1 -0
  131. package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
  132. package/dist/typescript/version.d.ts +1 -1
  133. package/dist/typescript/version.d.ts.map +1 -1
  134. package/expo-config-plugin/dist/withAndroidManifest.js +33 -1
  135. package/expo-config-plugin/dist/withAndroidPermissions.js +7 -2
  136. package/expo-config-plugin/dist/withAppDelegate.js +197 -19
  137. package/expo-config-plugin/dist/withMainActivity.js +1 -1
  138. package/expo-config-plugin/dist/withiOSInfoPlist.js +3 -2
  139. package/ios/StreamInCallManager.m +0 -2
  140. package/ios/StreamInCallManager.swift +7 -19
  141. package/ios/StreamVideoReactNative.h +4 -7
  142. package/ios/StreamVideoReactNative.m +82 -189
  143. package/package.json +19 -14
  144. package/src/hooks/push/index.ts +2 -0
  145. package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +235 -0
  146. package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +34 -21
  147. package/src/hooks/push/useProcessPushCallEffect.ts +108 -0
  148. package/src/hooks/useAndroidKeepCallAliveEffect.ts +120 -94
  149. package/src/index.ts +0 -1
  150. package/src/modules/call-manager/CallManager.ts +0 -36
  151. package/src/modules/call-manager/native-module.d.ts +0 -7
  152. package/src/providers/StreamCall/index.tsx +6 -6
  153. package/src/utils/StreamVideoRN/index.ts +30 -40
  154. package/src/utils/StreamVideoRN/types.ts +29 -56
  155. package/src/utils/internal/registerSDKGlobals.ts +4 -47
  156. package/src/utils/push/android.ts +309 -231
  157. package/src/utils/push/internal/ios.ts +44 -28
  158. package/src/utils/push/internal/rxSubjects.ts +61 -0
  159. package/src/utils/push/internal/utils.ts +26 -45
  160. package/src/utils/push/ios.ts +6 -1
  161. package/src/utils/push/libs/callkeep.ts +16 -0
  162. package/src/utils/push/libs/index.ts +2 -1
  163. package/src/utils/push/libs/notifee/index.ts +27 -0
  164. package/src/utils/push/libs/voipPushNotification.ts +17 -0
  165. package/src/utils/push/setupIosCallKeepEvents.ts +252 -0
  166. package/src/utils/push/setupIosVoipPushEvents.ts +7 -11
  167. package/src/version.ts +1 -1
  168. package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +0 -83
  169. package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +0 -149
  170. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +0 -121
  171. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
  172. package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js +0 -58
  173. package/dist/commonjs/utils/internal/callingx/audioSessionPromise.js.map +0 -1
  174. package/dist/commonjs/utils/internal/callingx/callingx.js +0 -109
  175. package/dist/commonjs/utils/internal/callingx/callingx.js.map +0 -1
  176. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +0 -48
  177. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +0 -1
  178. package/dist/commonjs/utils/push/libs/callingx.js +0 -75
  179. package/dist/commonjs/utils/push/libs/callingx.js.map +0 -1
  180. package/dist/commonjs/utils/push/setupCallingExpEvents.js +0 -108
  181. package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +0 -1
  182. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +0 -114
  183. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
  184. package/dist/module/utils/internal/callingx/audioSessionPromise.js +0 -51
  185. package/dist/module/utils/internal/callingx/audioSessionPromise.js.map +0 -1
  186. package/dist/module/utils/internal/callingx/callingx.js +0 -100
  187. package/dist/module/utils/internal/callingx/callingx.js.map +0 -1
  188. package/dist/module/utils/keepCallAliveHeadlessTask.js +0 -42
  189. package/dist/module/utils/keepCallAliveHeadlessTask.js.map +0 -1
  190. package/dist/module/utils/push/libs/callingx.js +0 -67
  191. package/dist/module/utils/push/libs/callingx.js.map +0 -1
  192. package/dist/module/utils/push/setupCallingExpEvents.js +0 -102
  193. package/dist/module/utils/push/setupCallingExpEvents.js.map +0 -1
  194. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +0 -5
  195. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +0 -1
  196. package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts +0 -16
  197. package/dist/typescript/utils/internal/callingx/audioSessionPromise.d.ts.map +0 -1
  198. package/dist/typescript/utils/internal/callingx/callingx.d.ts +0 -13
  199. package/dist/typescript/utils/internal/callingx/callingx.d.ts.map +0 -1
  200. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +0 -10
  201. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +0 -1
  202. package/dist/typescript/utils/push/libs/callingx.d.ts +0 -9
  203. package/dist/typescript/utils/push/libs/callingx.d.ts.map +0 -1
  204. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +0 -8
  205. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +0 -1
  206. package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +0 -147
  207. package/src/utils/internal/callingx/audioSessionPromise.ts +0 -53
  208. package/src/utils/internal/callingx/callingx.ts +0 -146
  209. package/src/utils/keepCallAliveHeadlessTask.ts +0 -54
  210. package/src/utils/push/libs/callingx.ts +0 -90
  211. package/src/utils/push/setupCallingExpEvents.ts +0 -130
@@ -1,11 +1,10 @@
1
- // import { getVoipPushNotificationLib } from './libs';
1
+ import { getVoipPushNotificationLib } from './libs';
2
2
 
3
3
  import { Platform } from 'react-native';
4
4
  import { onVoipNotificationReceived } from './internal/ios';
5
5
  import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
6
6
  import { StreamVideoConfig } from '../StreamVideoRN/types';
7
7
  import { videoLoggerSystem } from '@stream-io/video-client';
8
- import { getCallingxLib } from './libs';
9
8
 
10
9
  export function setupIosVoipPushEvents(
11
10
  pushConfig: NonNullable<StreamVideoConfig['push']>,
@@ -21,19 +20,16 @@ export function setupIosVoipPushEvents(
21
20
  );
22
21
  return;
23
22
  }
23
+ const voipPushNotification = getVoipPushNotificationLib();
24
24
 
25
- const callingx = getCallingxLib();
26
- const voipNotificationReceivedListener = callingx.addEventListener(
27
- 'voipNotificationReceived',
28
- (params) => {
29
- onVoipNotificationReceived(params, pushConfig);
30
- },
31
- );
32
-
25
+ logger.debug('notification event listener added');
26
+ voipPushNotification.addEventListener('notification', (notification) => {
27
+ onVoipNotificationReceived(notification, pushConfig);
28
+ });
33
29
  setPushLogoutCallback(async () => {
34
30
  videoLoggerSystem
35
31
  .getLogger('setPushLogoutCallback')
36
32
  .debug('notification event listener removed');
37
- voipNotificationReceivedListener.remove();
33
+ voipPushNotification.removeEventListener('notification');
38
34
  });
39
35
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.29.1-beta.0';
1
+ export const version = '1.29.2';
@@ -1,83 +0,0 @@
1
- package com.streamvideo.reactnative.keepalive
2
-
3
- import android.app.Notification
4
- import android.app.NotificationChannel
5
- import android.app.NotificationManager
6
- import android.app.PendingIntent
7
- import android.content.Context
8
- import android.content.Intent
9
- import android.content.pm.PackageManager
10
- import android.os.Build
11
- import androidx.core.app.NotificationCompat
12
-
13
- internal object KeepAliveNotification {
14
- private const val DEFAULT_CHANNEL_DESCRIPTION = "Stream call keep-alive"
15
-
16
- fun ensureChannel(
17
- context: Context,
18
- channelId: String,
19
- channelName: String
20
- ) {
21
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
22
- val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
23
- val existing = manager.getNotificationChannel(channelId)
24
- if (existing != null) return
25
-
26
- val channel = NotificationChannel(
27
- channelId,
28
- channelName,
29
- NotificationManager.IMPORTANCE_LOW
30
- ).apply {
31
- description = DEFAULT_CHANNEL_DESCRIPTION
32
- setShowBadge(false)
33
- }
34
- manager.createNotificationChannel(channel)
35
- }
36
-
37
- fun buildOngoingNotification(
38
- context: Context,
39
- channelId: String,
40
- title: String,
41
- body: String,
42
- smallIconName: String?
43
- ): Notification {
44
- val launchIntent = context.packageManager.getLaunchIntentForPackage(context.packageName)
45
- val pendingIntentFlags =
46
- PendingIntent.FLAG_UPDATE_CURRENT or
47
- PendingIntent.FLAG_IMMUTABLE
48
- val contentIntent = if (launchIntent != null) {
49
- PendingIntent.getActivity(context, 0, launchIntent, pendingIntentFlags)
50
- } else {
51
- // Fallback: empty intent to avoid crash if launch activity is missing for some reason
52
- PendingIntent.getActivity(context, 0, Intent(), pendingIntentFlags)
53
- }
54
-
55
- val iconResId = resolveSmallIconResId(context, smallIconName)
56
- return NotificationCompat.Builder(context, channelId)
57
- .setContentTitle(title)
58
- .setContentText(body)
59
- .setOngoing(true)
60
- .setOnlyAlertOnce(true)
61
- .setCategory(NotificationCompat.CATEGORY_CALL)
62
- .setContentIntent(contentIntent)
63
- .setSmallIcon(iconResId)
64
- .build()
65
- }
66
-
67
- private fun resolveSmallIconResId(context: Context, smallIconName: String?): Int {
68
- val resources = context.resources
69
- val packageName = context.packageName
70
- if (!smallIconName.isNullOrBlank()) {
71
- val id = resources.getIdentifier(smallIconName, "drawable", packageName)
72
- if (id != 0) return id
73
- }
74
- // Default to the app icon
75
- return try {
76
- val appInfo = context.packageManager.getApplicationInfo(packageName, 0)
77
- appInfo.icon
78
- } catch (_: PackageManager.NameNotFoundException) {
79
- android.R.drawable.ic_dialog_info
80
- }
81
- }
82
- }
83
-
@@ -1,149 +0,0 @@
1
- package com.streamvideo.reactnative.keepalive
2
-
3
- import android.Manifest
4
- import android.content.Intent
5
- import android.content.pm.PackageManager
6
- import android.content.pm.ServiceInfo
7
- import android.os.Build
8
- import android.util.Log
9
- import androidx.annotation.RequiresApi
10
- import androidx.core.app.ServiceCompat
11
- import androidx.core.content.ContextCompat
12
- import com.facebook.react.HeadlessJsTaskService
13
- import com.facebook.react.bridge.Arguments
14
- import com.facebook.react.jstasks.HeadlessJsTaskConfig
15
-
16
- /**
17
- * Foreground service that runs a React Native HeadlessJS task to keep a call alive.
18
- *
19
- */
20
- class StreamCallKeepAliveHeadlessService : HeadlessJsTaskService() {
21
-
22
- override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
23
- val safeIntent = intent ?: Intent()
24
- val channelId = safeIntent.getStringExtra(EXTRA_CHANNEL_ID) ?: DEFAULT_CHANNEL_ID
25
- val channelName = safeIntent.getStringExtra(EXTRA_CHANNEL_NAME) ?: DEFAULT_CHANNEL_NAME
26
- val title = safeIntent.getStringExtra(EXTRA_TITLE) ?: DEFAULT_TITLE
27
- val body = safeIntent.getStringExtra(EXTRA_BODY) ?: DEFAULT_BODY
28
- val smallIconName = safeIntent.getStringExtra(EXTRA_SMALL_ICON_NAME)
29
-
30
- KeepAliveNotification.ensureChannel(this, channelId, channelName)
31
- val notification = KeepAliveNotification.buildOngoingNotification(
32
- context = this,
33
- channelId = channelId,
34
- title = title,
35
- body = body,
36
- smallIconName = smallIconName
37
- )
38
-
39
- startForegroundCompat(notification)
40
-
41
- // Ensure HeadlessJS task is started
42
- return super.onStartCommand(safeIntent, flags, startId)
43
- }
44
-
45
- override fun getTaskConfig(intent: Intent?): HeadlessJsTaskConfig? {
46
- val callCid = intent?.getStringExtra(EXTRA_CALL_CID) ?: return null
47
- val data = Arguments.createMap().apply {
48
- putString("callCid", callCid)
49
- }
50
- // We intentionally allow long-running work (the JS task can return a never-resolving Promise).
51
- return HeadlessJsTaskConfig(
52
- TASK_NAME,
53
- data,
54
- 0, // timeout (0 = no timeout)
55
- true // allowedInForeground
56
- )
57
- }
58
-
59
- override fun onDestroy() {
60
- super.onDestroy()
61
- stopForeground(STOP_FOREGROUND_REMOVE)
62
- }
63
-
64
- @RequiresApi(Build.VERSION_CODES.R)
65
- private fun computeForegroundServiceTypes(): Int {
66
- var types = ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
67
-
68
- val hasCameraPermission =
69
- ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
70
- if (hasCameraPermission) {
71
- types = types or ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA
72
- }
73
-
74
- val hasMicrophonePermission =
75
- ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED
76
- if (hasMicrophonePermission) {
77
- types = types or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
78
- }
79
-
80
- return types
81
- }
82
-
83
- private fun startForegroundCompat(notification: android.app.Notification) {
84
- try {
85
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
86
- val types =
87
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) computeForegroundServiceTypes()
88
- else ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
89
- startForeground(NOTIFICATION_ID, notification, types)
90
- } else {
91
- startForeground(NOTIFICATION_ID, notification)
92
- }
93
- } catch (e: Exception) {
94
- // Avoid crashing the app if the system rejects starting a foreground service (e.g.
95
- // background start restrictions, invalid notification/channel, or permission issues).
96
- Log.e(
97
- TAG,
98
- "startForegroundCompat: Failed to start foreground service: ${e.message}",
99
- e
100
- )
101
- }
102
- }
103
-
104
- companion object {
105
- private const val TAG = "StreamCallKeepAliveHeadlessService"
106
-
107
- const val TASK_NAME = "StreamVideoKeepCallAlive"
108
-
109
- const val EXTRA_CALL_CID = "callCid"
110
- const val EXTRA_CHANNEL_ID = "channelId"
111
- const val EXTRA_CHANNEL_NAME = "channelName"
112
- const val EXTRA_TITLE = "title"
113
- const val EXTRA_BODY = "body"
114
- const val EXTRA_SMALL_ICON_NAME = "smallIconName"
115
-
116
- private const val NOTIFICATION_ID = 6061
117
-
118
- private const val DEFAULT_CHANNEL_ID = "stream_call_foreground_service"
119
- private const val DEFAULT_CHANNEL_NAME = "Call in progress"
120
- private const val DEFAULT_TITLE = "Call in progress"
121
- private const val DEFAULT_BODY = "Tap to return to the call"
122
-
123
- fun buildStartIntent(
124
- context: android.content.Context,
125
- callCid: String,
126
- channelId: String,
127
- channelName: String,
128
- title: String,
129
- body: String,
130
- smallIconName: String?
131
- ): Intent {
132
- return Intent(context, StreamCallKeepAliveHeadlessService::class.java).apply {
133
- putExtra(EXTRA_CALL_CID, callCid)
134
- putExtra(EXTRA_CHANNEL_ID, channelId)
135
- putExtra(EXTRA_CHANNEL_NAME, channelName)
136
- putExtra(EXTRA_TITLE, title)
137
- putExtra(EXTRA_BODY, body)
138
- if (!smallIconName.isNullOrBlank()) {
139
- putExtra(EXTRA_SMALL_ICON_NAME, smallIconName)
140
- }
141
- }
142
- }
143
-
144
- fun buildStopIntent(context: android.content.Context): Intent {
145
- return Intent(context, StreamCallKeepAliveHeadlessService::class.java)
146
- }
147
- }
148
- }
149
-
@@ -1,121 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useCallingExpWithCallingStateEffect = void 0;
7
- var _videoClient = require("@stream-io/video-client");
8
- var _videoReactBindings = require("@stream-io/video-react-bindings");
9
- var _react = require("react");
10
- var _callingx = require("../../utils/internal/callingx/callingx");
11
- var _callingx2 = require("../../utils/push/libs/callingx");
12
- const logger = _videoClient.videoLoggerSystem.getLogger('callingx');
13
-
14
- /**
15
- * This hook is used to inform sync call state with CallKit/Telecom (i.e. start call, end call, mute/unmute call).
16
- */
17
- const useCallingExpWithCallingStateEffect = () => {
18
- const {
19
- useMicrophoneState,
20
- useParticipants,
21
- useCallMembers
22
- } = (0, _videoReactBindings.useCallStateHooks)();
23
- const activeCall = (0, _videoReactBindings.useCall)();
24
- const {
25
- isMute,
26
- microphone
27
- } = useMicrophoneState();
28
- const callMembers = useCallMembers();
29
- const participants = useParticipants();
30
- const activeCallCid = activeCall?.cid;
31
- const currentUserId = activeCall?.currentUserId;
32
- const callDisplayName = (0, _react.useMemo)(() => (0, _callingx.getCallDisplayName)(callMembers, participants, currentUserId), [callMembers, participants, currentUserId]);
33
- (0, _react.useEffect)(() => {
34
- return () => {
35
- const callingx = (0, _callingx2.getCallingxLibIfAvailable)();
36
- if (!callingx?.isSetup || !activeCallCid) {
37
- return;
38
- }
39
- const isCallTracked = callingx.isCallTracked(activeCallCid);
40
- if (!isCallTracked) {
41
- logger.debug(`useCallingExpWithCallingStateEffect:No active call cid to end in calling exp: ${activeCallCid} isCallTracked: ${isCallTracked}`);
42
- return;
43
- }
44
- //if incoming stream call was unmounted, we need to end the call in CallKit/Telecom
45
- logger.debug(`useCallingExpWithCallingStateEffect: Ending call in callingx: ${activeCallCid}`);
46
- callingx.endCallWithReason(activeCallCid, 'local').catch(error => {
47
- logger.error(`useCallingExpWithCallingStateEffect: Error ending call in callingx: ${activeCallCid}`, error);
48
- });
49
- };
50
- }, [activeCallCid]);
51
- (0, _react.useEffect)(() => {
52
- const callingx = (0, _callingx2.getCallingxLibIfAvailable)();
53
- if (!callingx?.isSetup || !activeCallCid) {
54
- return;
55
- }
56
- const isCallTracked = callingx.isCallTracked(activeCallCid);
57
- if (!isCallTracked) {
58
- logger.debug(`useCallingExpWithCallingStateEffect:No active call cid to update callingx: ${activeCallCid} isCallTracked: ${isCallTracked}`);
59
- return;
60
- }
61
- callingx.updateDisplay(activeCallCid, activeCallCid, callDisplayName);
62
- }, [activeCallCid, callDisplayName]);
63
-
64
- // Sync microphone mute state from app → CallKit
65
- (0, _react.useEffect)(() => {
66
- const callingx = (0, _callingx2.getCallingxLibIfAvailable)();
67
- if (!callingx?.isSetup || !activeCallCid) {
68
- return;
69
- }
70
- const isCallTracked = callingx.isCallTracked(activeCallCid);
71
- if (!isCallTracked) {
72
- logger.debug(`useCallingExpWithCallingStateEffect: No active call cid to set muted in calling exp: ${activeCallCid} isCallTracked: ${isCallTracked}`);
73
- return;
74
- }
75
- callingx.setMutedCall(activeCallCid, isMute);
76
- }, [activeCallCid, isMute]);
77
-
78
- // Sync mute state from CallKit → app (only for system-initiated mute actions)
79
- (0, _react.useEffect)(() => {
80
- const callingx = (0, _callingx2.getCallingxLibIfAvailable)();
81
- if (!callingx?.isSetup || !activeCallCid) {
82
- logger.debug(`useCallingExpWithCallingStateEffect: No active call cid to set muted in calling exp: ${activeCallCid} callingx isSetup: ${callingx?.isSetup}`);
83
- return;
84
- }
85
-
86
- // Listen to mic toggle events from CallKit/Telecom and update stream call microphone state.
87
- // Only system-initiated mute actions (e.g. user tapped mute on the native CallKit UI)
88
- // are sent here — app-initiated actions are filtered out on the native side to prevent
89
- // the feedback loop: app mutes mic → setMutedCall → CallKit delegate → event to JS → loop.
90
- const subscription = callingx.addEventListener('didPerformSetMutedCallAction', async event => {
91
- const {
92
- callId,
93
- muted
94
- } = event;
95
- const isCallTracked = callingx.isCallTracked(activeCallCid);
96
- if (!isCallTracked || callId !== activeCallCid) {
97
- logger.debug(`useCallingExpWithCallingStateEffect: No active call cid to set muted in calling exp: ${activeCallCid} isCallTracked: ${isCallTracked} callId: ${callId}`);
98
- return;
99
- }
100
- const isCurrentlyMuted = microphone.state.status === 'disabled';
101
- if (isCurrentlyMuted === muted) {
102
- logger.debug(`useCallingExpWithCallingStateEffect: Mic toggle is already in the desired state: ${muted} for call: ${activeCallCid}`);
103
- return;
104
- }
105
- try {
106
- if (muted) {
107
- await microphone.disable();
108
- } else {
109
- await microphone.enable();
110
- }
111
- } catch (error) {
112
- logger.error(`useCallingExpWithCallingStateEffect: Error toggling mic in calling exp: ${activeCallCid}`, error);
113
- }
114
- });
115
- return () => {
116
- subscription.remove();
117
- };
118
- }, [activeCallCid, microphone]);
119
- };
120
- exports.useCallingExpWithCallingStateEffect = useCallingExpWithCallingStateEffect;
121
- //# sourceMappingURL=useCallingExpWithCallingStateEffect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_videoClient","require","_videoReactBindings","_react","_callingx","_callingx2","logger","videoLoggerSystem","getLogger","useCallingExpWithCallingStateEffect","useMicrophoneState","useParticipants","useCallMembers","useCallStateHooks","activeCall","useCall","isMute","microphone","callMembers","participants","activeCallCid","cid","currentUserId","callDisplayName","useMemo","getCallDisplayName","useEffect","callingx","getCallingxLibIfAvailable","isSetup","isCallTracked","debug","endCallWithReason","catch","error","updateDisplay","setMutedCall","subscription","addEventListener","event","callId","muted","isCurrentlyMuted","state","status","disable","enable","remove","exports"],"sourceRoot":"../../../../src","sources":["hooks/push/useCallingExpWithCallingStateEffect.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAEA,MAAMK,MAAM,GAAGC,8BAAiB,CAACC,SAAS,CAAC,UAAU,CAAC;;AAEtD;AACA;AACA;AACO,MAAMC,mCAAmC,GAAGA,CAAA,KAAM;EACvD,MAAM;IAAEC,kBAAkB;IAAEC,eAAe;IAAEC;EAAe,CAAC,GAC3D,IAAAC,qCAAiB,EAAC,CAAC;EAErB,MAAMC,UAAU,GAAG,IAAAC,2BAAO,EAAC,CAAC;EAC5B,MAAM;IAAEC,MAAM;IAAEC;EAAW,CA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AAC;MAC3D,IAAI,CAACU,aAAa,IAAIU,MAAM,KAAKpB,aAAa,EAAE;QAC9Cd,MAAM,CAACyB,KAAK,CACV,wFAAwFX,aAAa,mBAAmBU,aAAa,YAAYU,MAAM,EACzJ,CAAC;QACD;MACF;MAEA,MAAME,gBAAgB,GAAGzB,UAAU,CAAC0B,KAAK,CAACC,MAAM,KAAK,UAAU;MAC/D,IAAIF,gBAAgB,KAAKD,KAAK,EAAE;QAC9BnC,MAAM,CAACyB,KAAK,CACV,oFAAoFU,KAAK,cAAcrB,aAAa,EACtH,CAAC;QACD;MACF;MAEA,IAAI;QACF,IAAIqB,KAAK,EAAE;UACT,MAAMxB,UAAU,CAAC4B,OAAO,CAAC,CAAC;QAC5B,CAAC,MAAM;UACL,MAAM5B,UAAU,CAAC6B,MAAM,CAAC,CAAC;QAC3B;MACF,CAAC,CAAC,OAAOZ,KAAc,EAAE;QACvB5B,MAAM,CAAC4B,KAAK,CACV,2EAA2Ed,aAAa,EAAE,EAC1Fc,KACF,CAAC;MACH;IACF,CACF,CAAC;IAED,OAAO,MAAM;MACXG,YAAY,CAACU,MAAM,CAAC,CAAC;IACvB,CAAC;EACH,CAAC,EAAE,CAAC3B,aAAa,EAAEH,UAAU,CAAC,CAAC;AACjC,CAAC;AAAC+B,OAAA,CAAAvC,mCAAA,GAAAA,mCAAA","ignoreList":[]}
@@ -1,58 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.resolvePendingAudioSession = resolvePendingAudioSession;
7
- exports.waitForAudioSessionActivation = waitForAudioSessionActivation;
8
- /**
9
- * Module to manage pending promise for audio session activation.
10
- * Used to wait for iOS CallKit's didActivateAudioSession event after starting a call.
11
- */
12
-
13
- let pendingResolve = null;
14
- let pendingTimeout = null;
15
- /**
16
- * Flag to check if the audio session is already activated.
17
- * This solves race condition for a cold start case, when the audio session is activated before the promise is created.
18
- */
19
- let isAudioSessionAlreadyActivated = false;
20
- const AUDIO_SESSION_TIMEOUT_MS = 5000;
21
-
22
- /**
23
- * Creates a promise that resolves when the audio session is activated,
24
- * or after a timeout to prevent hanging indefinitely.
25
- * @returns Promise that resolves when audio session is activated or timeout occurs
26
- */
27
- function waitForAudioSessionActivation() {
28
- if (isAudioSessionAlreadyActivated) {
29
- isAudioSessionAlreadyActivated = false;
30
- return Promise.resolve();
31
- }
32
- return new Promise(resolve => {
33
- pendingResolve = resolve;
34
- pendingTimeout = setTimeout(() => {
35
- // Resolve on timeout to prevent hanging
36
- resolvePendingAudioSession();
37
- }, AUDIO_SESSION_TIMEOUT_MS);
38
- });
39
- }
40
-
41
- /**
42
- * Resolves the pending audio session activation promise.
43
- * Called when the didActivateAudioSession event fires or on timeout.
44
- */
45
- function resolvePendingAudioSession() {
46
- if (pendingTimeout) {
47
- clearTimeout(pendingTimeout);
48
- pendingTimeout = null;
49
- }
50
- if (pendingResolve) {
51
- pendingResolve();
52
- pendingResolve = null;
53
- isAudioSessionAlreadyActivated = false;
54
- } else {
55
- isAudioSessionAlreadyActivated = true;
56
- }
57
- }
58
- //# sourceMappingURL=audioSessionPromise.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["pendingResolve","pendingTimeout","isAudioSessionAlreadyActivated","AUDIO_SESSION_TIMEOUT_MS","waitForAudioSessionActivation","Promise","resolve","setTimeout","resolvePendingAudioSession","clearTimeout"],"sourceRoot":"../../../../../src","sources":["utils/internal/callingx/audioSessionPromise.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;;AAEA,IAAIA,cAAmC,GAAG,IAAI;AAC9C,IAAIC,cAAoD,GAAG,IAAI;AAC/D;AACA;AACA;AACA;AACA,IAAIC,8BAA8B,GAAG,KAAK;AAE1C,MAAMC,wBAAwB,GAAG,IAAI;;AAErC;AACA;AACA;AACA;AACA;AACO,SAASC,6BAA6BA,CAAA,EAAkB;EAC7D,IAAIF,8BAA8B,EAAE;IAClCA,8BAA8B,GAAG,KAAK;IACtC,OAAOG,OAAO,CAACC,OAAO,CAAC,CAAC;EAC1B;EAEA,OAAO,IAAID,OAAO,CAAEC,OAAO,IAAK;IAC9BN,cAAc,GAAGM,OAAO;IACxBL,cAAc,GAAGM,UAAU,CAAC,MAAM;MAChC;MACAC,0BAA0B,CAAC,CAAC;IAC9B,CAAC,EAAEL,wBAAwB,CAAC;EAC9B,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACO,SAASK,0BAA0BA,CAAA,EAAS;EACjD,IAAIP,cAAc,EAAE;IAClBQ,YAAY,CAACR,cAAc,CAAC;IAC5BA,cAAc,GAAG,IAAI;EACvB;EAEA,IAAID,cAAc,EAAE;IAClBA,cAAc,CAAC,CAAC;IAChBA,cAAc,GAAG,IAAI;IACrBE,8BAA8B,GAAG,KAAK;EACxC,CAAC,MAAM;IACLA,8BAA8B,GAAG,IAAI;EACvC;AACF","ignoreList":[]}
@@ -1,109 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.endCallingxCall = endCallingxCall;
7
- exports.getCallDisplayName = getCallDisplayName;
8
- exports.startCallingxCall = startCallingxCall;
9
- var _reactNative = require("react-native");
10
- var _callingx = require("../../push/libs/callingx");
11
- var _videoClient = require("@stream-io/video-client");
12
- var _audioSessionPromise = require("./audioSessionPromise");
13
- /***
14
- * Internal utils for callingx library usage from video-client.
15
- * See @./registerSDKGlobals.ts for more usage details.
16
- */
17
-
18
- const CallingxModule = (0, _callingx.getCallingxLibIfAvailable)();
19
-
20
- /**
21
- * Gets the call display name. To be used for display in native call screen.
22
- */
23
- function getCallDisplayName(callMembers, participants, currentUserId) {
24
- if (!callMembers || !participants || !currentUserId) {
25
- return 'Call';
26
- }
27
- let names = [];
28
- if (callMembers.length > 0) {
29
- // for ringing calls, members array contains all call members from the very early state and participants array is empty in the beginning
30
- names = callMembers.filter(member => member.user.id !== currentUserId).map(member => member.user.name).filter(name => name !== undefined);
31
- } else if (participants.length > 0) {
32
- // for non-ringing calls, members array is empty and we rely on participants array there
33
- names = participants.filter(participant => participant.userId !== currentUserId).map(participant => participant.name).filter(Boolean);
34
- }
35
-
36
- // if no names are found, we use the name of the current user
37
- if (names.length === 0) {
38
- names = [participants.find(participant => participant.userId === currentUserId)?.name ?? 'Call'];
39
- }
40
- return names.sort().join(', ');
41
- }
42
-
43
- /**
44
- * Starts the call in the callingx library.
45
- * Must be called for all outgoing calls
46
- * and optionally for non-ringing calls when ongoing calls are enabled.
47
- */
48
- async function startCallingxCall(call) {
49
- if (!CallingxModule || !CallingxModule.isSetup) {
50
- return;
51
- }
52
- const logger = _videoClient.videoLoggerSystem.getLogger('callingx');
53
- const isOutcomingCall = call.ringing && call.isCreatedByMe;
54
- const isIncomingCall = call.ringing && !call.isCreatedByMe;
55
- const callDisplayName = getCallDisplayName(call.state.members, call.state.participants, call.currentUserId);
56
- if (!CallingxModule.isCallTracked(call.cid) && (isOutcomingCall || !call.ringing && CallingxModule.isOngoingCallsEnabled)) {
57
- try {
58
- await CallingxModule.startCall(call.cid,
59
- // unique id for call
60
- call.id,
61
- // phone number for display in dialer (we use call id as phone number)
62
- callDisplayName,
63
- // display name for display in call screen
64
- call.state.settings?.video?.enabled ?? false // is video call?
65
- );
66
-
67
- // Wait for audio session activation on iOS only
68
- if (_reactNative.Platform.OS === 'ios') {
69
- await (0, _audioSessionPromise.waitForAudioSessionActivation)();
70
- }
71
-
72
- // TODO: this must be done after join call is complete
73
- CallingxModule.setCurrentCallActive(call.cid);
74
- } catch (error) {
75
- logger.error(`startCallingxCall: Error starting call in callingx: ${call.cid}`, error);
76
- }
77
- } else if (isIncomingCall) {
78
- try {
79
- // Awaits native CallKit/Telecom registration before answering.
80
- // Safe to call even if the call is already registered (e.g. from VoIP push) --
81
- // iOS early-returns with no error, Android sends the registered broadcast.
82
- await CallingxModule.displayIncomingCall(call.cid,
83
- // unique id for call
84
- call.id,
85
- // phone number for display in dialer (we use call id as phone number)
86
- callDisplayName,
87
- // display name for display in call screen
88
- call.state.settings?.video?.enabled ?? false // is video call?
89
- );
90
- await CallingxModule.answerIncomingCall(call.cid);
91
- if (_reactNative.Platform.OS === 'ios') {
92
- await (0, _audioSessionPromise.waitForAudioSessionActivation)();
93
- }
94
- } catch (error) {
95
- logger.error(`Error displaying incoming call in callingx: ${call.cid}`, error);
96
- }
97
- }
98
- }
99
- async function endCallingxCall(call) {
100
- if (!CallingxModule || !CallingxModule.isSetup || !CallingxModule.isCallTracked(call.cid)) {
101
- return;
102
- }
103
- try {
104
- await CallingxModule.endCallWithReason(call.cid, 'local');
105
- } catch (error) {
106
- _videoClient.videoLoggerSystem.getLogger('callingx').error(`endCallingxCall: Error ending call in callingx: ${call.cid}`, error);
107
- }
108
- }
109
- //# sourceMappingURL=callingx.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","_callingx","_videoClient","_audioSessionPromise","CallingxModule","getCallingxLibIfAvailable","getCallDisplayName","callMembers","participants","currentUserId","names","length","filter","member","user","id","map","name","undefined","participant","userId","Boolean","find","sort","join","startCallingxCall","call","isSetup","logger","videoLoggerSystem","getLogger","isOutcomingCall","ringing","isCreatedByMe","isIncomingCall","callDisplayName","state","members","isCallTracked","cid","isOngoingCallsEnabled","startCall","settings","video","enabled","Platform","OS","waitForAudioSessionActivation","setCurrentCallActive","error","displayIncomingCall","answerIncomingCall","endCallingxCall","endCallWithReason"],"sourceRoot":"../../../../../src","sources":["utils/internal/callingx/callingx.ts"],"mappings":";;;;;;;;AAIA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAMA,IAAAG,oBAAA,GAAAH,OAAA;AAZA;AACA;AACA;AACA;;AAWA,MAAMI,cAAc,GAAG,IAAAC,mCAAyB,EAAC,CAAC;;AAElD;AACA;AACA;AACO,SAASC,kBAAkBA,CAChCC,WAAyC,EACzCC,YAAkD,EAClDC,aAAiC,EACjC;EACA,IAAI,CAACF,WAAW,IA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AE,KAAK,KAAK,EAAE;QACzB,MAAM,IAAAC,kDAA6B,EAAC,CAAC;MACvC;IACF,CAAC,CAAC,OAAOE,KAAK,EAAE;MACdrB,MAAM,CAACqB,KAAK,CACV,+CAA+CvB,IAAI,CAACa,GAAG,EAAE,EACzDU,KACF,CAAC;IACH;EACF;AACF;AAEO,eAAeG,eAAeA,CAAC1B,IAAU,EAAE;EAChD,IACE,CAACtB,cAAc,IACf,CAACA,cAAc,CAACuB,OAAO,IACvB,CAACvB,cAAc,CAACkC,aAAa,CAACZ,IAAI,CAACa,GAAG,CAAC,EACvC;IACA;EACF;EAEA,IAAI;IACF,MAAMnC,cAAc,CAACiD,iBAAiB,CAAC3B,IAAI,CAACa,GAAG,EAAE,OAAO,CAAC;EAC3D,CAAC,CAAC,OAAOU,KAAK,EAAE;IACdpB,8BAAiB,CACdC,SAAS,CAAC,UAAU,CAAC,CACrBmB,KAAK,CACJ,mDAAmDvB,IAAI,CAACa,GAAG,EAAE,EAC7DU,KACF,CAAC;EACL;AACF","ignoreList":[]}
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.keepCallAliveCallRef = exports.KEEP_CALL_ALIVE_HEADLESS_TASK_NAME = void 0;
7
- var _reactNative = require("react-native");
8
- var _videoClient = require("@stream-io/video-client");
9
- var _StreamVideoRN = require("./StreamVideoRN");
10
- const KEEP_CALL_ALIVE_HEADLESS_TASK_NAME = exports.KEEP_CALL_ALIVE_HEADLESS_TASK_NAME = 'StreamVideoKeepCallAlive';
11
-
12
- /**
13
- * The keep-alive headless task needs access to the active `Call` instance.
14
- * The keep-alive hook will set this reference before starting the native service.
15
- */
16
- const keepCallAliveCallRef = exports.keepCallAliveCallRef = {
17
- current: undefined
18
- };
19
- function registerKeepCallAliveHeadlessTaskOnce() {
20
- if (_reactNative.Platform.OS !== 'android') return;
21
- _reactNative.AppRegistry.registerHeadlessTask(KEEP_CALL_ALIVE_HEADLESS_TASK_NAME, () => async data => {
22
- const logger = _videoClient.videoLoggerSystem.getLogger('KEEP_CALL_ALIVE_HEADLESS_TASK');
23
- const callCid = data?.callCid;
24
- const call = keepCallAliveCallRef.current;
25
- if (!call) {
26
- logger.warn('No active call instance available for keep-alive task; skipping.', {
27
- callCid
28
- });
29
- return;
30
- }
31
- if (callCid && call.cid && call.cid !== callCid) {
32
- logger.warn('Keep-alive task callCid does not match active call; skipping.', {
33
- callCid,
34
- activeCallCid: call.cid
35
- });
36
- return;
37
- }
38
- const config = _StreamVideoRN.StreamVideoRN.getConfig();
39
- const taskToRun = config.foregroundService.android.taskToRun;
40
- try {
41
- await taskToRun(call);
42
- } catch (e) {
43
- logger.error('Keep-alive headless task failed', e);
44
- }
45
- });
46
- }
47
- registerKeepCallAliveHeadlessTaskOnce();
48
- //# sourceMappingURL=keepCallAliveHeadlessTask.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","_videoClient","_StreamVideoRN","KEEP_CALL_ALIVE_HEADLESS_TASK_NAME","exports","keepCallAliveCallRef","current","undefined","registerKeepCallAliveHeadlessTaskOnce","Platform","OS","AppRegistry","registerHeadlessTask","data","logger","videoLoggerSystem","getLogger","callCid","call","warn","cid","activeCallCid","config","StreamVideoRN","getConfig","taskToRun","foregroundService","android","e","error"],"sourceRoot":"../../../src","sources":["utils/keepCallAliveHeadlessTask.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAEO,MAAMG,kCAAkC,GAAAC,OAAA,CAAAD,kCAAA,GAAG,0BAA0B;;AAE5E;AACA;AACA;AACA;AACO,MAAME,oBAAmD,GAAAD,OAAA,CAAAC,oBAAA,GAAG;EACjEC,OAAO,EAAEC;AACX,CAAC;AAED,SAASC,qCAAqCA,CAAA,EAAG;EAC/C,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;EAE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