@stream-io/video-react-native-sdk 1.29.0-beta.3 → 1.29.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.
Files changed (224) hide show
  1. package/CHANGELOG.md +3126 -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/components/Call/CallContent/CallContent.js +7 -2
  9. package/dist/commonjs/components/Call/CallContent/CallContent.js.map +1 -1
  10. package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js +8 -1
  11. package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
  12. package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js +3 -0
  13. package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
  14. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +160 -0
  15. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
  16. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
  17. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  18. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +97 -64
  19. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  20. package/dist/commonjs/index.js +0 -1
  21. package/dist/commonjs/index.js.map +1 -1
  22. package/dist/commonjs/modules/call-manager/CallManager.js +0 -26
  23. package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
  24. package/dist/commonjs/providers/StreamCall/index.js +6 -6
  25. package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
  26. package/dist/commonjs/utils/StreamVideoRN/index.js +21 -33
  27. package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
  28. package/dist/commonjs/utils/internal/registerSDKGlobals.js +15 -52
  29. package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
  30. package/dist/commonjs/utils/push/android.js +202 -155
  31. package/dist/commonjs/utils/push/android.js.map +1 -1
  32. package/dist/commonjs/utils/push/internal/ios.js +32 -16
  33. package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
  34. package/dist/commonjs/utils/push/internal/rxSubjects.js +20 -1
  35. package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
  36. package/dist/commonjs/utils/push/internal/utils.js +16 -28
  37. package/dist/commonjs/utils/push/internal/utils.js.map +1 -1
  38. package/dist/commonjs/utils/push/ios.js.map +1 -1
  39. package/dist/commonjs/utils/push/libs/callkeep.js +17 -0
  40. package/dist/commonjs/utils/push/libs/callkeep.js.map +1 -0
  41. package/dist/commonjs/utils/push/libs/index.js +19 -8
  42. package/dist/commonjs/utils/push/libs/index.js.map +1 -1
  43. package/dist/commonjs/utils/push/libs/notifee/index.js +19 -0
  44. package/dist/commonjs/utils/push/libs/notifee/index.js.map +1 -1
  45. package/dist/commonjs/utils/push/libs/voipPushNotification.js +17 -0
  46. package/dist/commonjs/utils/push/libs/voipPushNotification.js.map +1 -0
  47. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +205 -0
  48. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +1 -0
  49. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +6 -7
  50. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
  51. package/dist/commonjs/version.js +1 -1
  52. package/dist/commonjs/version.js.map +1 -1
  53. package/dist/module/components/Call/CallContent/CallContent.js +7 -2
  54. package/dist/module/components/Call/CallContent/CallContent.js.map +1 -1
  55. package/dist/module/components/Call/CallContent/RTCViewPipIOS.js +8 -1
  56. package/dist/module/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
  57. package/dist/module/components/Call/CallContent/RTCViewPipNative.js +3 -0
  58. package/dist/module/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
  59. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +153 -0
  60. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -0
  61. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +31 -18
  62. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  63. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +99 -66
  64. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  65. package/dist/module/index.js +0 -1
  66. package/dist/module/index.js.map +1 -1
  67. package/dist/module/modules/call-manager/CallManager.js +0 -26
  68. package/dist/module/modules/call-manager/CallManager.js.map +1 -1
  69. package/dist/module/providers/StreamCall/index.js +6 -6
  70. package/dist/module/providers/StreamCall/index.js.map +1 -1
  71. package/dist/module/utils/StreamVideoRN/index.js +21 -33
  72. package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
  73. package/dist/module/utils/internal/registerSDKGlobals.js +16 -53
  74. package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
  75. package/dist/module/utils/push/android.js +204 -157
  76. package/dist/module/utils/push/android.js.map +1 -1
  77. package/dist/module/utils/push/internal/ios.js +32 -16
  78. package/dist/module/utils/push/internal/ios.js.map +1 -1
  79. package/dist/module/utils/push/internal/rxSubjects.js +19 -0
  80. package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
  81. package/dist/module/utils/push/internal/utils.js +15 -25
  82. package/dist/module/utils/push/internal/utils.js.map +1 -1
  83. package/dist/module/utils/push/ios.js.map +1 -1
  84. package/dist/module/utils/push/libs/callkeep.js +11 -0
  85. package/dist/module/utils/push/libs/callkeep.js.map +1 -0
  86. package/dist/module/utils/push/libs/index.js +2 -1
  87. package/dist/module/utils/push/libs/index.js.map +1 -1
  88. package/dist/module/utils/push/libs/notifee/index.js +18 -0
  89. package/dist/module/utils/push/libs/notifee/index.js.map +1 -1
  90. package/dist/module/utils/push/libs/voipPushNotification.js +11 -0
  91. package/dist/module/utils/push/libs/voipPushNotification.js.map +1 -0
  92. package/dist/module/utils/push/setupIosCallKeepEvents.js +199 -0
  93. package/dist/module/utils/push/setupIosCallKeepEvents.js.map +1 -0
  94. package/dist/module/utils/push/setupIosVoipPushEvents.js +6 -7
  95. package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
  96. package/dist/module/version.js +1 -1
  97. package/dist/module/version.js.map +1 -1
  98. package/dist/typescript/components/Call/CallContent/CallContent.d.ts +2 -2
  99. package/dist/typescript/components/Call/CallContent/CallContent.d.ts.map +1 -1
  100. package/dist/typescript/components/Call/CallContent/RTCViewPipIOS.d.ts +4 -0
  101. package/dist/typescript/components/Call/CallContent/RTCViewPipIOS.d.ts.map +1 -1
  102. package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts +9 -6
  103. package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts.map +1 -1
  104. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts +5 -0
  105. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +1 -0
  106. package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
  107. package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
  108. package/dist/typescript/index.d.ts +0 -1
  109. package/dist/typescript/index.d.ts.map +1 -1
  110. package/dist/typescript/modules/call-manager/CallManager.d.ts +0 -5
  111. package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
  112. package/dist/typescript/utils/StreamVideoRN/index.d.ts +2 -20
  113. package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
  114. package/dist/typescript/utils/StreamVideoRN/types.d.ts +29 -54
  115. package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
  116. package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
  117. package/dist/typescript/utils/push/android.d.ts +2 -1
  118. package/dist/typescript/utils/push/android.d.ts.map +1 -1
  119. package/dist/typescript/utils/push/internal/ios.d.ts.map +1 -1
  120. package/dist/typescript/utils/push/internal/rxSubjects.d.ts +12 -0
  121. package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
  122. package/dist/typescript/utils/push/internal/utils.d.ts +1 -8
  123. package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
  124. package/dist/typescript/utils/push/ios.d.ts +2 -1
  125. package/dist/typescript/utils/push/ios.d.ts.map +1 -1
  126. package/dist/typescript/utils/push/libs/callkeep.d.ts +3 -0
  127. package/dist/typescript/utils/push/libs/callkeep.d.ts.map +1 -0
  128. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts +2 -16
  129. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
  130. package/dist/typescript/utils/push/libs/index.d.ts +2 -1
  131. package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
  132. package/dist/typescript/utils/push/libs/notifee/index.d.ts +1 -0
  133. package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
  134. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +3 -0
  135. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +1 -0
  136. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +6 -0
  137. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +1 -0
  138. package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
  139. package/dist/typescript/version.d.ts +1 -1
  140. package/dist/typescript/version.d.ts.map +1 -1
  141. package/expo-config-plugin/dist/withAndroidManifest.js +33 -1
  142. package/expo-config-plugin/dist/withAndroidPermissions.js +7 -2
  143. package/expo-config-plugin/dist/withAppDelegate.js +197 -19
  144. package/expo-config-plugin/dist/withMainActivity.js +1 -1
  145. package/expo-config-plugin/dist/withiOSInfoPlist.js +3 -2
  146. package/ios/PictureInPicture/StreamAVPictureInPictureVideoCallViewController.swift +8 -0
  147. package/ios/PictureInPicture/StreamPictureInPictureController.swift +8 -0
  148. package/ios/PictureInPicture/StreamPictureInPictureVideoRenderer.swift +10 -0
  149. package/ios/RTCViewPip.swift +6 -0
  150. package/ios/RTCViewPipManager.mm +1 -0
  151. package/ios/StreamInCallManager.m +0 -2
  152. package/ios/StreamInCallManager.swift +7 -19
  153. package/ios/StreamVideoReactNative.h +4 -7
  154. package/ios/StreamVideoReactNative.m +102 -191
  155. package/package.json +19 -14
  156. package/src/components/Call/CallContent/CallContent.tsx +6 -1
  157. package/src/components/Call/CallContent/RTCViewPipIOS.tsx +18 -2
  158. package/src/components/Call/CallContent/RTCViewPipNative.tsx +4 -7
  159. package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +235 -0
  160. package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +34 -21
  161. package/src/hooks/useAndroidKeepCallAliveEffect.ts +120 -94
  162. package/src/index.ts +0 -1
  163. package/src/modules/call-manager/CallManager.ts +0 -36
  164. package/src/modules/call-manager/native-module.d.ts +0 -7
  165. package/src/providers/StreamCall/index.tsx +6 -6
  166. package/src/utils/StreamVideoRN/index.ts +30 -40
  167. package/src/utils/StreamVideoRN/types.ts +29 -56
  168. package/src/utils/internal/registerSDKGlobals.ts +23 -47
  169. package/src/utils/push/android.ts +309 -231
  170. package/src/utils/push/internal/ios.ts +42 -27
  171. package/src/utils/push/internal/rxSubjects.ts +29 -0
  172. package/src/utils/push/internal/utils.ts +15 -38
  173. package/src/utils/push/ios.ts +6 -1
  174. package/src/utils/push/libs/callkeep.ts +16 -0
  175. package/src/utils/push/libs/index.ts +2 -1
  176. package/src/utils/push/libs/notifee/index.ts +27 -0
  177. package/src/utils/push/libs/voipPushNotification.ts +17 -0
  178. package/src/utils/push/setupIosCallKeepEvents.ts +252 -0
  179. package/src/utils/push/setupIosVoipPushEvents.ts +7 -11
  180. package/src/version.ts +1 -1
  181. package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +0 -83
  182. package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +0 -134
  183. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +0 -121
  184. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
  185. package/dist/commonjs/utils/internal/audioSessionPromise.js +0 -57
  186. package/dist/commonjs/utils/internal/audioSessionPromise.js.map +0 -1
  187. package/dist/commonjs/utils/internal/callingx.js +0 -136
  188. package/dist/commonjs/utils/internal/callingx.js.map +0 -1
  189. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +0 -48
  190. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +0 -1
  191. package/dist/commonjs/utils/push/libs/callingx.js +0 -75
  192. package/dist/commonjs/utils/push/libs/callingx.js.map +0 -1
  193. package/dist/commonjs/utils/push/setupCallingExpEvents.js +0 -97
  194. package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +0 -1
  195. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +0 -114
  196. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +0 -1
  197. package/dist/module/utils/internal/audioSessionPromise.js +0 -50
  198. package/dist/module/utils/internal/audioSessionPromise.js.map +0 -1
  199. package/dist/module/utils/internal/callingx.js +0 -127
  200. package/dist/module/utils/internal/callingx.js.map +0 -1
  201. package/dist/module/utils/keepCallAliveHeadlessTask.js +0 -42
  202. package/dist/module/utils/keepCallAliveHeadlessTask.js.map +0 -1
  203. package/dist/module/utils/push/libs/callingx.js +0 -67
  204. package/dist/module/utils/push/libs/callingx.js.map +0 -1
  205. package/dist/module/utils/push/setupCallingExpEvents.js +0 -91
  206. package/dist/module/utils/push/setupCallingExpEvents.js.map +0 -1
  207. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +0 -5
  208. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +0 -1
  209. package/dist/typescript/utils/internal/audioSessionPromise.d.ts +0 -16
  210. package/dist/typescript/utils/internal/audioSessionPromise.d.ts.map +0 -1
  211. package/dist/typescript/utils/internal/callingx.d.ts +0 -13
  212. package/dist/typescript/utils/internal/callingx.d.ts.map +0 -1
  213. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +0 -10
  214. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +0 -1
  215. package/dist/typescript/utils/push/libs/callingx.d.ts +0 -9
  216. package/dist/typescript/utils/push/libs/callingx.d.ts.map +0 -1
  217. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +0 -8
  218. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +0 -1
  219. package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +0 -147
  220. package/src/utils/internal/audioSessionPromise.ts +0 -52
  221. package/src/utils/internal/callingx.ts +0 -192
  222. package/src/utils/keepCallAliveHeadlessTask.ts +0 -54
  223. package/src/utils/push/libs/callingx.ts +0 -90
  224. package/src/utils/push/setupCallingExpEvents.ts +0 -117
@@ -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,134 +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 androidx.annotation.RequiresApi
9
- import androidx.core.app.ServiceCompat
10
- import androidx.core.content.ContextCompat
11
- import com.facebook.react.HeadlessJsTaskService
12
- import com.facebook.react.bridge.Arguments
13
- import com.facebook.react.jstasks.HeadlessJsTaskConfig
14
-
15
- /**
16
- * Foreground service that runs a React Native HeadlessJS task to keep a call alive.
17
- *
18
- */
19
- class StreamCallKeepAliveHeadlessService : HeadlessJsTaskService() {
20
-
21
- override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
22
- val safeIntent = intent ?: Intent()
23
- val channelId = safeIntent.getStringExtra(EXTRA_CHANNEL_ID) ?: DEFAULT_CHANNEL_ID
24
- val channelName = safeIntent.getStringExtra(EXTRA_CHANNEL_NAME) ?: DEFAULT_CHANNEL_NAME
25
- val title = safeIntent.getStringExtra(EXTRA_TITLE) ?: DEFAULT_TITLE
26
- val body = safeIntent.getStringExtra(EXTRA_BODY) ?: DEFAULT_BODY
27
- val smallIconName = safeIntent.getStringExtra(EXTRA_SMALL_ICON_NAME)
28
-
29
- KeepAliveNotification.ensureChannel(this, channelId, channelName)
30
- val notification = KeepAliveNotification.buildOngoingNotification(
31
- context = this,
32
- channelId = channelId,
33
- title = title,
34
- body = body,
35
- smallIconName = smallIconName
36
- )
37
-
38
- startForegroundCompat(notification)
39
-
40
- // Ensure HeadlessJS task is started
41
- return super.onStartCommand(safeIntent, flags, startId)
42
- }
43
-
44
- override fun getTaskConfig(intent: Intent?): HeadlessJsTaskConfig? {
45
- val callCid = intent?.getStringExtra(EXTRA_CALL_CID) ?: return null
46
- val data = Arguments.createMap().apply {
47
- putString("callCid", callCid)
48
- }
49
- // We intentionally allow long-running work (the JS task can return a never-resolving Promise).
50
- return HeadlessJsTaskConfig(
51
- TASK_NAME,
52
- data,
53
- 0, // timeout (0 = no timeout)
54
- true // allowedInForeground
55
- )
56
- }
57
-
58
- override fun onDestroy() {
59
- super.onDestroy()
60
- stopForeground(STOP_FOREGROUND_REMOVE)
61
- }
62
-
63
- @RequiresApi(Build.VERSION_CODES.R)
64
- private fun computeForegroundServiceTypes(): Int {
65
- var types = ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
66
-
67
- val hasCameraPermission =
68
- ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
69
- if (hasCameraPermission) {
70
- types = types or ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA
71
- }
72
-
73
- val hasMicrophonePermission =
74
- ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED
75
- if (hasMicrophonePermission) {
76
- types = types or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
77
- }
78
-
79
- return types
80
- }
81
-
82
- private fun startForegroundCompat(notification: android.app.Notification) {
83
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
84
- val types = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) computeForegroundServiceTypes() else ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
85
- startForeground(NOTIFICATION_ID, notification, types)
86
- } else {
87
- startForeground(NOTIFICATION_ID, notification)
88
- }
89
- }
90
-
91
- companion object {
92
- const val TASK_NAME = "StreamVideoKeepCallAlive"
93
-
94
- const val EXTRA_CALL_CID = "callCid"
95
- const val EXTRA_CHANNEL_ID = "channelId"
96
- const val EXTRA_CHANNEL_NAME = "channelName"
97
- const val EXTRA_TITLE = "title"
98
- const val EXTRA_BODY = "body"
99
- const val EXTRA_SMALL_ICON_NAME = "smallIconName"
100
-
101
- private const val NOTIFICATION_ID = 6061
102
-
103
- private const val DEFAULT_CHANNEL_ID = "stream_call_foreground_service"
104
- private const val DEFAULT_CHANNEL_NAME = "Call in progress"
105
- private const val DEFAULT_TITLE = "Call in progress"
106
- private const val DEFAULT_BODY = "Tap to return to the call"
107
-
108
- fun buildStartIntent(
109
- context: android.content.Context,
110
- callCid: String,
111
- channelId: String,
112
- channelName: String,
113
- title: String,
114
- body: String,
115
- smallIconName: String?
116
- ): Intent {
117
- return Intent(context, StreamCallKeepAliveHeadlessService::class.java).apply {
118
- putExtra(EXTRA_CALL_CID, callCid)
119
- putExtra(EXTRA_CHANNEL_ID, channelId)
120
- putExtra(EXTRA_CHANNEL_NAME, channelName)
121
- putExtra(EXTRA_TITLE, title)
122
- putExtra(EXTRA_BODY, body)
123
- if (!smallIconName.isNullOrBlank()) {
124
- putExtra(EXTRA_SMALL_ICON_NAME, smallIconName)
125
- }
126
- }
127
- }
128
-
129
- fun buildStopIntent(context: android.content.Context): Intent {
130
- return Intent(context, StreamCallKeepAliveHeadlessService::class.java)
131
- }
132
- }
133
- }
134
-
@@ -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");
11
- var _callingx2 = require("../../utils/push/libs/callingx");
12
- const logger = _videoClient.videoLoggerSystem.getLogger('Callingx - useCallingExpWithCallingStateEffect');
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 isCallRegistered = callingx.isCallRegistered(activeCallCid);
40
- if (!isCallRegistered) {
41
- logger.debug(`No active call cid to end in calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered}`);
42
- return;
43
- }
44
- //if incoming stream call was unmounted, we need to end the call in CallKit/Telecom
45
- logger.debug(`Ending call in callingx: ${activeCallCid}`);
46
- callingx.endCallWithReason(activeCallCid, 'local').catch(error => {
47
- logger.error(`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 isCallRegistered = callingx.isCallRegistered(activeCallCid);
57
- if (!isCallRegistered) {
58
- logger.debug(`No active call cid to update callingx: ${activeCallCid} isCallRegistered: ${isCallRegistered}`);
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 isCallRegistered = callingx.isCallRegistered(activeCallCid);
71
- if (!isCallRegistered) {
72
- logger.debug(`No active call cid to set muted in calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered}`);
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(`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 isCallRegistered = callingx.isCallRegistered(activeCallCid);
96
- if (!isCallRegistered || callId !== activeCallCid) {
97
- logger.debug(`No active call cid to set muted in calling exp: ${activeCallCid} isCallRegistered: ${isCallRegistered} callId: ${callId}`);
98
- return;
99
- }
100
- const isCurrentlyMuted = microphone.state.status === 'disabled';
101
- if (isCurrentlyMuted === muted) {
102
- logger.debug(`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(`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","isCallRegistered","debug","endCallWithReason","catch","error","updateDisplay","setMutedCall","subscription","addEventListener","event","callId","muted","isCurrentlyMuted","state","status","disable","enable","remove","exports"],"sour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AM;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,57 +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
- return Promise.resolve();
30
- }
31
- return new Promise(resolve => {
32
- pendingResolve = resolve;
33
- pendingTimeout = setTimeout(() => {
34
- // Resolve on timeout to prevent hanging
35
- resolvePendingAudioSession();
36
- }, AUDIO_SESSION_TIMEOUT_MS);
37
- });
38
- }
39
-
40
- /**
41
- * Resolves the pending audio session activation promise.
42
- * Called when the didActivateAudioSession event fires or on timeout.
43
- */
44
- function resolvePendingAudioSession() {
45
- if (pendingTimeout) {
46
- clearTimeout(pendingTimeout);
47
- pendingTimeout = null;
48
- }
49
- if (pendingResolve) {
50
- pendingResolve();
51
- pendingResolve = null;
52
- isAudioSessionAlreadyActivated = false;
53
- } else {
54
- isAudioSessionAlreadyActivated = true;
55
- }
56
- }
57
- //# 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/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;IAClC,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,136 +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 isOutcomingCall = call.ringing && call.isCreatedByMe;
53
- const isIncomingCall = call.ringing && !call.isCreatedByMe;
54
- const callDisplayName = getCallDisplayName(call.state.members, call.state.participants, call.currentUserId);
55
- if (!CallingxModule.isCallRegistered(call.cid) && (isOutcomingCall || !call.ringing && CallingxModule.isOngoingCallsEnabled)) {
56
- try {
57
- await CallingxModule.startCall(call.cid,
58
- // unique id for call
59
- call.id,
60
- // phone number for display in dialer (we use call id as phone number)
61
- callDisplayName,
62
- // display name for display in call screen
63
- call.state.settings?.video?.enabled ?? false // is video call?
64
- );
65
-
66
- // Wait for audio session activation on iOS only
67
- if (_reactNative.Platform.OS === 'ios') {
68
- await (0, _audioSessionPromise.waitForAudioSessionActivation)();
69
- }
70
- CallingxModule.setCurrentCallActive(call.cid);
71
- } catch (error) {
72
- _videoClient.videoLoggerSystem.getLogger('startCallingxCall').error(`Error starting call in callingx: ${call.cid}`, error);
73
- }
74
- } else if (isIncomingCall) {
75
- try {
76
- if (!CallingxModule.isCallRegistered(call.cid)) {
77
- await CallingxModule.displayIncomingCall(call.cid,
78
- // unique id for call
79
- call.id,
80
- // phone number for display in dialer (we use call id as phone number)
81
- callDisplayName,
82
- // display name for display in call screen
83
- call.state.settings?.video?.enabled ?? false // is video call?
84
- );
85
- await waitForDisplayIncomingCall(call.cid);
86
- } else {
87
- await CallingxModule.answerIncomingCall(call.cid);
88
- }
89
- if (_reactNative.Platform.OS === 'ios') {
90
- await (0, _audioSessionPromise.waitForAudioSessionActivation)();
91
- }
92
- } catch (error) {
93
- _videoClient.videoLoggerSystem.getLogger('startCallingxCall').error(`Error displaying incoming call in callingx: ${call.cid}`, error);
94
- }
95
- }
96
- }
97
- async function endCallingxCall(call) {
98
- if (!CallingxModule || !CallingxModule.isSetup || !CallingxModule.isCallRegistered(call.cid)) {
99
- return;
100
- }
101
- try {
102
- await CallingxModule.endCallWithReason(call.cid, 'local');
103
- } catch (error) {
104
- _videoClient.videoLoggerSystem.getLogger('endCallingxCall').error(`Error ending call in callingx: ${call.cid}`, error);
105
- }
106
- }
107
- const waitForDisplayIncomingCall = (callId, timeoutMs = 5000) => {
108
- if (!CallingxModule) {
109
- return Promise.resolve();
110
- }
111
- return new Promise((resolve, reject) => {
112
- let timeoutId = undefined;
113
- let subscription = undefined;
114
- const cleanup = () => {
115
- if (timeoutId) {
116
- clearTimeout(timeoutId);
117
- }
118
- subscription?.remove();
119
- };
120
- subscription = CallingxModule.addEventListener('didDisplayIncomingCall', async params => {
121
- _videoClient.videoLoggerSystem.getLogger('waitForDisplayIncomingCall').debug('didDisplayIncomingCall', params);
122
- cleanup();
123
- try {
124
- await CallingxModule.answerIncomingCall(callId);
125
- resolve();
126
- } catch (error) {
127
- reject(error);
128
- }
129
- });
130
- timeoutId = setTimeout(() => {
131
- cleanup();
132
- reject(new Error(`Timeout waiting for didDisplayIncomingCall after ${timeoutMs}ms`));
133
- }, timeoutMs);
134
- });
135
- };
136
- //# 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","isOutcomingCall","ringing","isCreatedByMe","isIncomingCall","callDisplayName","state","members","isCallRegistered","cid","isOngoingCallsEnabled","startCall","settings","video","enabled","Platform","OS","waitForAudioSessionActivation","setCurrentCallActive","error","videoLoggerSystem","getLogger","displayIncomingCall","waitForDisplayIncomingCall","answerIncomingCall","endCallingxCall","endCallWithReason","callId","timeoutMs","Promise","resolve","reject","timeoutId","subscription","cleanup","clearTimeout","remove","addEventListener","params","debug","setTimeout","Error"],"sourceRoot":"../../../../src","sources":["utils/internal/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,IAAI,CAACC,YAAY,IAAI,CAACC,aAAa,EAAE;IACnD,OAAO,MAAM;EACf;EAEA,IAAIC,KAAe,GAAG,EAAE;EAExB,IAAIH,WAAW,CAACI,MAAM,GAAG,CAAC,EAAE;I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,CAAC,wBAAwB,EAAED,MAAM,CAAC;MAC1CJ,OAAO,CAAC,CAAC;MAET,IAAI;QACF,MAAMzD,cAAc,CAAC+C,kBAAkB,CAACG,MAAM,CAAC;QAC/CG,OAAO,CAAC,CAAC;MACX,CAAC,CAAC,OAAOX,KAAK,EAAE;QACdY,MAAM,CAACZ,KAAK,CAAC;MACf;IACF,CACF,CAAC;IAEDa,SAAS,GAAGQ,UAAU,CAAC,MAAM;MAC3BN,OAAO,CAAC,CAAC;MACTH,MAAM,CACJ,IAAIU,KAAK,CACP,oDAAoDb,SAAS,IAC/D,CACF,CAAC;IACH,CAAC,EAAEA,SAAS,CAAC;EACf,CAAC,CAAC;AACJ,CAAC","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/BC,wBAAW,CAACC,oBAAoB,CAC9BT,kCAAkC,EAClC,MAAM,MAAOU,IAAsC,IAAK;IACtD,MAAMC,MAAM,GAAGC,8BAAiB,CAACC,SAAS,CACxC,+BACF,CAAC;IACD,MAAMC,OAAO,GAAGJ,IAAI,EAAEI,OAAO;IAE7B,MAAMC,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