@stream-io/video-react-native-sdk 1.28.1 → 1.29.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/android/src/main/AndroidManifest.xml +8 -1
  2. package/android/src/main/AndroidManifestNew.xml +11 -0
  3. package/android/src/main/java/com/streamvideo/reactnative/StreamVideoReactNativeModule.kt +42 -5
  4. package/android/src/main/java/com/streamvideo/reactnative/keepalive/KeepAliveNotification.kt +83 -0
  5. package/android/src/main/java/com/streamvideo/reactnative/keepalive/StreamCallKeepAliveHeadlessService.kt +134 -0
  6. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +235 -0
  7. package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -0
  8. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +18 -31
  9. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  10. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +60 -97
  11. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  12. package/dist/commonjs/index.js +1 -0
  13. package/dist/commonjs/index.js.map +1 -1
  14. package/dist/commonjs/modules/call-manager/CallManager.js +20 -0
  15. package/dist/commonjs/modules/call-manager/CallManager.js.map +1 -1
  16. package/dist/commonjs/providers/StreamCall/index.js +6 -6
  17. package/dist/commonjs/providers/StreamCall/index.js.map +1 -1
  18. package/dist/commonjs/utils/StreamVideoRN/index.js +33 -21
  19. package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
  20. package/dist/commonjs/utils/internal/registerSDKGlobals.js +47 -3
  21. package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
  22. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js +48 -0
  23. package/dist/commonjs/utils/keepCallAliveHeadlessTask.js.map +1 -0
  24. package/dist/commonjs/utils/push/android.js +145 -200
  25. package/dist/commonjs/utils/push/android.js.map +1 -1
  26. package/dist/commonjs/utils/push/internal/ios.js +16 -34
  27. package/dist/commonjs/utils/push/internal/ios.js.map +1 -1
  28. package/dist/commonjs/utils/push/internal/rxSubjects.js +1 -20
  29. package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -1
  30. package/dist/commonjs/utils/push/internal/utils.js +17 -1
  31. package/dist/commonjs/utils/push/internal/utils.js.map +1 -1
  32. package/dist/commonjs/utils/push/ios.js.map +1 -1
  33. package/dist/commonjs/utils/push/libs/callingx.js +75 -0
  34. package/dist/commonjs/utils/push/libs/callingx.js.map +1 -0
  35. package/dist/commonjs/utils/push/libs/index.js +8 -19
  36. package/dist/commonjs/utils/push/libs/index.js.map +1 -1
  37. package/dist/commonjs/utils/push/libs/notifee/index.js +0 -19
  38. package/dist/commonjs/utils/push/libs/notifee/index.js.map +1 -1
  39. package/dist/commonjs/utils/push/setupCallingExpEvents.js +75 -0
  40. package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +1 -0
  41. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +7 -6
  42. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
  43. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +228 -0
  44. package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -0
  45. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +18 -31
  46. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  47. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +62 -99
  48. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  49. package/dist/module/index.js +1 -0
  50. package/dist/module/index.js.map +1 -1
  51. package/dist/module/modules/call-manager/CallManager.js +20 -0
  52. package/dist/module/modules/call-manager/CallManager.js.map +1 -1
  53. package/dist/module/providers/StreamCall/index.js +6 -6
  54. package/dist/module/providers/StreamCall/index.js.map +1 -1
  55. package/dist/module/utils/StreamVideoRN/index.js +33 -21
  56. package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
  57. package/dist/module/utils/internal/registerSDKGlobals.js +48 -4
  58. package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
  59. package/dist/module/utils/keepCallAliveHeadlessTask.js +42 -0
  60. package/dist/module/utils/keepCallAliveHeadlessTask.js.map +1 -0
  61. package/dist/module/utils/push/android.js +147 -202
  62. package/dist/module/utils/push/android.js.map +1 -1
  63. package/dist/module/utils/push/internal/ios.js +16 -34
  64. package/dist/module/utils/push/internal/ios.js.map +1 -1
  65. package/dist/module/utils/push/internal/rxSubjects.js +0 -19
  66. package/dist/module/utils/push/internal/rxSubjects.js.map +1 -1
  67. package/dist/module/utils/push/internal/utils.js +14 -0
  68. package/dist/module/utils/push/internal/utils.js.map +1 -1
  69. package/dist/module/utils/push/ios.js.map +1 -1
  70. package/dist/module/utils/push/libs/callingx.js +67 -0
  71. package/dist/module/utils/push/libs/callingx.js.map +1 -0
  72. package/dist/module/utils/push/libs/index.js +1 -2
  73. package/dist/module/utils/push/libs/index.js.map +1 -1
  74. package/dist/module/utils/push/libs/notifee/index.js +0 -18
  75. package/dist/module/utils/push/libs/notifee/index.js.map +1 -1
  76. package/dist/module/utils/push/setupCallingExpEvents.js +69 -0
  77. package/dist/module/utils/push/setupCallingExpEvents.js.map +1 -0
  78. package/dist/module/utils/push/setupIosVoipPushEvents.js +7 -6
  79. package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
  80. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts +5 -0
  81. package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +1 -0
  82. package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
  83. package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
  84. package/dist/typescript/index.d.ts +1 -0
  85. package/dist/typescript/index.d.ts.map +1 -1
  86. package/dist/typescript/modules/call-manager/CallManager.d.ts.map +1 -1
  87. package/dist/typescript/utils/StreamVideoRN/index.d.ts +20 -2
  88. package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
  89. package/dist/typescript/utils/StreamVideoRN/types.d.ts +54 -29
  90. package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
  91. package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
  92. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts +10 -0
  93. package/dist/typescript/utils/keepCallAliveHeadlessTask.d.ts.map +1 -0
  94. package/dist/typescript/utils/push/android.d.ts +1 -2
  95. package/dist/typescript/utils/push/android.d.ts.map +1 -1
  96. package/dist/typescript/utils/push/internal/ios.d.ts.map +1 -1
  97. package/dist/typescript/utils/push/internal/rxSubjects.d.ts +0 -12
  98. package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -1
  99. package/dist/typescript/utils/push/internal/utils.d.ts +4 -0
  100. package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
  101. package/dist/typescript/utils/push/ios.d.ts +1 -2
  102. package/dist/typescript/utils/push/ios.d.ts.map +1 -1
  103. package/dist/typescript/utils/push/libs/callingx.d.ts +9 -0
  104. package/dist/typescript/utils/push/libs/callingx.d.ts.map +1 -0
  105. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts +16 -2
  106. package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
  107. package/dist/typescript/utils/push/libs/index.d.ts +1 -2
  108. package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
  109. package/dist/typescript/utils/push/libs/notifee/index.d.ts +0 -1
  110. package/dist/typescript/utils/push/libs/notifee/index.d.ts.map +1 -1
  111. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts +8 -0
  112. package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +1 -0
  113. package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
  114. package/expo-config-plugin/dist/withAndroidManifest.js +1 -33
  115. package/expo-config-plugin/dist/withAndroidPermissions.js +2 -7
  116. package/expo-config-plugin/dist/withAppDelegate.js +19 -197
  117. package/expo-config-plugin/dist/withMainActivity.js +1 -1
  118. package/expo-config-plugin/dist/withiOSInfoPlist.js +2 -3
  119. package/ios/StreamInCallManager.swift +4 -0
  120. package/ios/StreamVideoReactNative.h +7 -4
  121. package/ios/StreamVideoReactNative.m +191 -82
  122. package/package.json +10 -15
  123. package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +361 -0
  124. package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +21 -34
  125. package/src/hooks/useAndroidKeepCallAliveEffect.ts +95 -120
  126. package/src/index.ts +1 -0
  127. package/src/modules/call-manager/CallManager.ts +30 -0
  128. package/src/providers/StreamCall/index.tsx +6 -6
  129. package/src/utils/StreamVideoRN/index.ts +40 -30
  130. package/src/utils/StreamVideoRN/types.ts +56 -29
  131. package/src/utils/internal/registerSDKGlobals.ts +42 -4
  132. package/src/utils/keepCallAliveHeadlessTask.ts +54 -0
  133. package/src/utils/push/android.ts +223 -308
  134. package/src/utils/push/internal/ios.ts +25 -46
  135. package/src/utils/push/internal/rxSubjects.ts +0 -29
  136. package/src/utils/push/internal/utils.ts +25 -0
  137. package/src/utils/push/ios.ts +1 -6
  138. package/src/utils/push/libs/callingx.ts +90 -0
  139. package/src/utils/push/libs/index.ts +1 -2
  140. package/src/utils/push/libs/notifee/index.ts +0 -27
  141. package/src/utils/push/setupCallingExpEvents.ts +100 -0
  142. package/src/utils/push/setupIosVoipPushEvents.ts +11 -7
  143. package/CHANGELOG.md +0 -3089
  144. package/android/src/main/java/com/streamvideo/reactnative/util/CallAliveServiceChecker.kt +0 -95
  145. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +0 -160
  146. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +0 -1
  147. package/dist/commonjs/utils/push/libs/callkeep.js +0 -17
  148. package/dist/commonjs/utils/push/libs/callkeep.js.map +0 -1
  149. package/dist/commonjs/utils/push/libs/voipPushNotification.js +0 -17
  150. package/dist/commonjs/utils/push/libs/voipPushNotification.js.map +0 -1
  151. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +0 -205
  152. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +0 -1
  153. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +0 -153
  154. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +0 -1
  155. package/dist/module/utils/push/libs/callkeep.js +0 -11
  156. package/dist/module/utils/push/libs/callkeep.js.map +0 -1
  157. package/dist/module/utils/push/libs/voipPushNotification.js +0 -11
  158. package/dist/module/utils/push/libs/voipPushNotification.js.map +0 -1
  159. package/dist/module/utils/push/setupIosCallKeepEvents.js +0 -199
  160. package/dist/module/utils/push/setupIosCallKeepEvents.js.map +0 -1
  161. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts +0 -5
  162. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +0 -1
  163. package/dist/typescript/utils/push/libs/callkeep.d.ts +0 -3
  164. package/dist/typescript/utils/push/libs/callkeep.d.ts.map +0 -1
  165. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts +0 -3
  166. package/dist/typescript/utils/push/libs/voipPushNotification.d.ts.map +0 -1
  167. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts +0 -6
  168. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +0 -1
  169. package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +0 -235
  170. package/src/utils/push/libs/callkeep.ts +0 -16
  171. package/src/utils/push/libs/voipPushNotification.ts +0 -17
  172. package/src/utils/push/setupIosCallKeepEvents.ts +0 -252
@@ -1 +1 @@
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,GAAG,CAAC,KAAKC,SAAS,EAAE;MAC7B,IACE,OAAOH,MAAM,CAACE,GAAG,CAAC,KAAK,QAAQ,IAC/BF,MAAM,CAACE,GAAG,CAAC,KAAK,IAAI,IACpB,CAACE,KAAK,CAACC,OAAO,CAACL,MAAM,CAACE,GAAG,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CAACb,IAAI,CAACgB,QAAQ,CAAC;IACjD;IACA,OAAO,MAAM;MACXK,iCAAwB,CAACR,OAAO,GAC9BQ,iCAAwB,CAACR,OAAO,EAAES,MAAM,CAAEC,EAAE,IAAKA,EAAE,KAAKP,QAAQ,CAAC;IACrE,CAAC;EACH;;EAEA;AACF;AACA;EACE,aAAaQ,YAAYA,CAAA,EAAG;IAC1B,OAAOC,0BAAa,CAACC,sBAAsB,CAACF,YAAY,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;EACE,aAAaG,YAAYA,CAAA,EAAG;IAC1B,OAAOF,0BAAa,CAACC,sBAAsB,CAACC,YAAY,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;AACA;EACE,aAAaC,6BAA6BA,CAAA,EAAqB;IAC7D,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAC3B,MAAM,IAAIvB,KAAK,CACb,qEACF,CAAC;IACH,OAAOkB,0BAAa,CAACC,sBAAsB,CAACK,sBAAsB,CAAC,CAAC;EACtE;;EAEA;AACF;AACA;AACA;EACE,aAAaC,4BAA4BA,CAAA,EAAqB;IAC5D,IAAIH,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAC3B,MAAM,IAAIvB,KAAK,CACb,oEACF,CAAC;IACH,OAAOkB,0BAAa,CAACC,sBAAsB,CAACO,qBAAqB,CAAC,CAAC;EACrE;;EAEA;AACF;AACA;AACA;EACE,aAAaC,wBAAwBA,CAAA,EAAqB;IACxD,IAAIL,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAC3B,MAAM,IAAIvB,KAAK,CACb,gEACF,CAAC;IACH,OAAOkB,0BAAa,CAACC,sBAAsB,CAACS,iBAAiB,CAAC,CAAC;EACjE;AACF;AAACC,OAAA,CAAA3C,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["_pushLogoutCallback","_interopRequireDefault","require","_newNotificationCallbacks","_setupIosVoipPushEvents","_setupCallingExpEvents","_callingx","_reactNative","_videoClient","e","__esModule","default","deepMerge","target","source","result","key","undefined","Array","isArray","DEFAULT_STREAM_VIDEO_CONFIG","foregroundService","android","channel","id","name","notificationTexts","title","body","taskToRun","Promise","StreamVideoRN","config","busyToneTimeout","updateConfig","setPushConfig","pushConfig","push","callingx","getCallingxLib","videoLoggerSystem","getLogger","info","JSON","stringify","options","extractCallingExpOptions","setup","Error","setupCallingExpEvents","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,sBAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAIA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAA4D,SAAAD,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE5D;;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,GAAG,CAAC,KAAKC,SAAS,EAAE;MAC7B,IACE,OAAOH,MAAM,CAACE,GAAG,CAAC,KAAK,QAAQ,IAC/BF,MAAM,CAACE,GAAG,CAAC,KAAK,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MAAM;MACLK,iCAAwB,CAACR,OAAO,CAACjB,IAAI,CAACoB,QAAQ,CAAC;IACjD;IACA,OAAO,MAAM;MACXK,iCAAwB,CAACR,OAAO,GAC9BQ,iCAAwB,CAACR,OAAO,EAAES,MAAM,CAAEC,EAAE,IAAKA,EAAE,KAAKP,QAAQ,CAAC;IACrE,CAAC;EACH;;EAEA;AACF;AACA;EACE,aAAaQ,YAAYA,CAAA,EAAG;IAC1B,OAAOC,0BAAa,CAACC,sBAAsB,CAACF,YAAY,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;EACE,aAAaG,YAAYA,CAAA,EAAG;IAC1B,OAAOF,0BAAa,CAACC,sBAAsB,CAACC,YAAY,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;AACA;EACE,aAAaC,6BAA6BA,CAAA,EAAqB;IAC7D,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAC3B,MAAM,IAAIvB,KAAK,CACb,qEACF,CAAC;IACH,OAAOkB,0BAAa,CAACC,sBAAsB,CAACK,sBAAsB,CAAC,CAAC;EACtE;;EAEA;AACF;AACA;AACA;EACE,aAAaC,4BAA4BA,CAAA,EAAqB;IAC5D,IAAIH,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAC3B,MAAM,IAAIvB,KAAK,CACb,oEACF,CAAC;IACH,OAAOkB,0BAAa,CAACC,sBAAsB,CAACO,qBAAqB,CAAC,CAAC;EACrE;;EAEA;AACF;AACA;AACA;EACE,aAAaC,wBAAwBA,CAAA,EAAqB;IACxD,IAAIL,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAC3B,MAAM,IAAIvB,KAAK,CACb,gEACF,CAAC;IACH,OAAOkB,0BAAa,CAACC,sBAAsB,CAACS,iBAAiB,CAAC,CAAC;EACjE;AACF;AAACC,OAAA,CAAA9C,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -5,19 +5,63 @@ 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");
8
9
  const StreamInCallManagerNativeModule = _reactNative.NativeModules.StreamInCallManager;
10
+ const CallingxModule = (0, _callingx.getCallingxLibIfAvailable)();
11
+
12
+ /**
13
+ * Checks if StreamInCallManager should be bypassed because CallKit is handling
14
+ * the audio session via CallingX.
15
+ *
16
+ * On iOS, when CallingX is set up and has a registered call, the audio session
17
+ * is managed by CallKit through CallingxImpl.swift.
18
+ * In this case, StreamInCallManager should not run to avoid conflicting audio
19
+ * session configurations.
20
+ */
21
+ const shouldBypassForCallKit = ({
22
+ isRingingTypeCall
23
+ }) => {
24
+ if (_reactNative.Platform.OS !== 'ios') {
25
+ return false;
26
+ }
27
+ if (!CallingxModule) {
28
+ return false;
29
+ }
30
+ const bypass = CallingxModule.isSetup && (isRingingTypeCall || CallingxModule.isOngoingCallsEnabled);
31
+ return bypass;
32
+ };
9
33
  const streamRNVideoSDKGlobals = {
10
34
  callManager: {
11
35
  setup: ({
12
- defaultDevice
36
+ defaultDevice,
37
+ isRingingTypeCall
13
38
  }) => {
39
+ if (shouldBypassForCallKit({
40
+ isRingingTypeCall
41
+ })) {
42
+ return;
43
+ }
14
44
  StreamInCallManagerNativeModule.setDefaultAudioDeviceEndpointType(defaultDevice);
15
45
  StreamInCallManagerNativeModule.setup();
16
46
  },
17
- start: () => {
47
+ start: ({
48
+ isRingingTypeCall
49
+ }) => {
50
+ if (shouldBypassForCallKit({
51
+ isRingingTypeCall
52
+ })) {
53
+ return;
54
+ }
18
55
  StreamInCallManagerNativeModule.start();
19
56
  },
20
- stop: () => {
57
+ stop: ({
58
+ isRingingTypeCall
59
+ }) => {
60
+ if (shouldBypassForCallKit({
61
+ isRingingTypeCall
62
+ })) {
63
+ return;
64
+ }
21
65
  StreamInCallManagerNativeModule.stop();
22
66
  }
23
67
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","StreamInCallManagerNativeModule","NativeModules","StreamInCallManager","streamRNVideoSDKGlobals","callManager","setup","defaultDevice","setDefaultAudioDeviceEndpointType","start","stop","registerSDKGlobals","global","streamRNVideoSDK"],"sourceRoot":"../../../../src","sources":["utils/internal/registerSDKGlobals.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,+BAA+B,GAAGC,0BAAa,CAACC,mBAAmB;AAEzE,MAAMC,uBAAgD,GAAG;EACvDC,WAAW,EAAE;IACXC,KAAK,EAAEA,CAAC;MAAEC;IAAc,CAAC,KAAK;MAC5BN,+BAA+B,CAACO,iCAAiC,CAC/DD,aACF,CAAC;MACDN,+BAA+B,CAACK,KAAK,CAAC,CAAC;IACzC,CAAC;IACDG,KAAK,EAAEA,CAAA,KAAM;MACXR,+BAA+B,CAACQ,KAAK,CAAC,CAAC;IACzC,CAAC;IACDC,IAAI,EAAEA,CAAA,KAAM;MACVT,+BAA+B,CAACS,IAAI,CAAC,CAAC;IACxC;EACF;AACF,CAAC;;AAED;AACA;AACA;AACO,SAASC,kBAAkBA,CAAA,EAAG;EACnC,IAAI,CAACC,MAAM,CAACC,gBAAgB,EAAE;IAC5BD,MAAM,CAACC,gBAAgB,GAAGT,uBAAuB;EACnD;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_callingx","StreamInCallManagerNativeModule","NativeModules","StreamInCallManager","CallingxModule","getCallingxLibIfAvailable","shouldBypassForCallKit","isRingingTypeCall","Platform","OS","bypass","isSetup","isOngoingCallsEnabled","streamRNVideoSDKGlobals","callManager","setup","defaultDevice","setDefaultAudioDeviceEndpointType","start","stop","registerSDKGlobals","global","streamRNVideoSDK"],"sourceRoot":"../../../../src","sources":["utils/internal/registerSDKGlobals.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,MAAME,+BAA+B,GAAGC,0BAAa,CAACC,mBAAmB;AAEzE,MAAMC,cAAc,GAAG,IAAAC,mCAAyB,EAAC,CAAC;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,sBAAsB,GAAGA,CAAC;EAC9BC;AAGF,CAAC,KAAc;EACb,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;IACzB,OAAO,KAAK;EACd;EACA,IAAI,CAACL,cAAc,EAAE;IACnB,OAAO,KAAK;EACd;EACA,MAAMM,MAAM,GACVN,cAAc,CAACO,OAAO,KACrBJ,iBAAiB,IAAIH,cAAc,CAACQ,qBAAqB,CAAC;EAC7D,OAAOF,MAAM;AACf,CAAC;AAED,MAAMG,uBAAgD,GAAG;EACvDC,WAAW,EAAE;IACXC,KAAK,EAAEA,CAAC;MAAEC,aAAa;MAAET;IAAkB,CAAC,KAAK;MAC/C,IAAID,sBAAsB,CAAC;QAAEC;MAAkB,CAAC,CAAC,EAAE;QACjD;MACF;MACAN,+BAA+B,CAACgB,iCAAiC,CAC/DD,aACF,CAAC;MACDf,+BAA+B,CAACc,KAAK,CAAC,CAAC;IACzC,CAAC;IACDG,KAAK,EAAEA,CAAC;MAAEX;IAAkB,CAAC,KAAK;MAChC,IAAID,sBAAsB,CAAC;QAAEC;MAAkB,CAAC,CAAC,EAAE;QACjD;MACF;MACAN,+BAA+B,CAACiB,KAAK,CAAC,CAAC;IACzC,CAAC;IACDC,IAAI,EAAEA,CAAC;MAAEZ;IAAkB,CAAC,KAAK;MAC/B,IAAID,sBAAsB,CAAC;QAAEC;MAAkB,CAAC,CAAC,EAAE;QACjD;MACF;MACAN,+BAA+B,CAACkB,IAAI,CAAC,CAAC;IACxC;EACF;AACF,CAAC;;AAED;AACA;AACA;AACO,SAASC,kBAAkBA,CAAA,EAAG;EACnC,IAAI,CAACC,MAAM,CAACC,gBAAgB,EAAE;IAC5BD,MAAM,CAACC,gBAAgB,GAAGT,uBAAuB;EACnD;AACF","ignoreList":[]}
@@ -0,0 +1,48 @@
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
@@ -0,0 +1 @@
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,IAAI,GAAGb,oBAAoB,CAACC,OAAO;IACzC,IAAI,CAACY,IAAI,EAAE;MACTJ,MAAM,CAACK,IAAI,CACT,kEAAkE,EAClE;QAAEF;MAAQ,CACZ,CAAC;MACD;IACF;IACA,IAAIA,OAAO,IAAIC,IAAI,CAACE,GAAG,IAAIF,IAAI,CAACE,GAAG,KAAKH,OAAO,EAAE;MAC/CH,MAAM,CAACK,IAAI,CACT,+DAA+D,EAC/D;QAAEF,OAAO;QAAEI,aAAa,EAAEH,IAAI,CAACE;MAAI,CACrC,CAAC;MACD;IACF;IAEA,MAAME,MAAM,GAAGC,4BAAa,CAACC,SAAS,CAAC,CAAC;IACxC,MAAMC,SAAS,GAAGH,MAAM,CAACI,iBAAiB,CAACC,OAAO,CAACF,SAAS;IAC5D,IAAI;MACF,MAAMA,SAAS,CAACP,IAAI,CAAC;IACvB,CAAC,CAAC,OAAOU,CAAC,EAAE;MACVd,MAAM,CAACe,KAAK,CAAC,iCAAiC,EAAED,CAAC,CAAC;IACpD;EACF,CACF,CAAC;AACH;AAEApB,qCAAqC,CAAC,CAAC","ignoreList":[]}
@@ -13,10 +13,8 @@ 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");
17
16
  var _StreamVideoRN = require("../StreamVideoRN");
18
- const ACCEPT_CALL_ACTION_ID = 'accept';
19
- const DECLINE_CALL_ACTION_ID = 'decline';
17
+ var _callingx = require("./libs/callingx");
20
18
  let lastFirebaseToken = {
21
19
  token: '',
22
20
  userId: ''
@@ -71,8 +69,7 @@ async function initAndroidPushToken(client, pushConfig, setUnsubscribeListener)
71
69
  await setDeviceToken(token);
72
70
  }
73
71
  }
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)();
72
+ const messaging = pushConfig.isExpo ? (0, _libs.getFirebaseMessagingLibNoThrow)(true) : (0, _libs.getFirebaseMessagingLib)();
76
73
  if (messaging) {
77
74
  logger.debug(`setting firebase token listeners`);
78
75
  const unsubscribe = messaging().onTokenRefresh(refreshedToken => setDeviceToken(refreshedToken));
@@ -86,8 +83,8 @@ async function initAndroidPushToken(client, pushConfig, setUnsubscribeListener)
86
83
  * Creates notification from the push message data.
87
84
  * For Ringing and Non-Ringing calls.
88
85
  */
86
+
89
87
  const firebaseDataHandler = async data => {
90
- if (_reactNative.Platform.OS !== 'android') return;
91
88
  /* Example data from firebase
92
89
  "message": {
93
90
  "data": {
@@ -103,174 +100,167 @@ const firebaseDataHandler = async data => {
103
100
  // other stuff
104
101
  }
105
102
  */
103
+ if (_reactNative.Platform.OS !== 'android') return;
104
+ const logger = _videoClient.videoLoggerSystem.getLogger('firebaseDataHandler');
106
105
  const pushConfig = _StreamVideoRN.StreamVideoRN.getConfig().push;
107
106
  if (!pushConfig || !data || data.sender !== 'stream.video') {
108
107
  return;
109
108
  }
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
- }
118
109
  if (data.type === 'call.ring') {
119
110
  const call_cid = data.call_cid;
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();
111
+ if (!call_cid) {
112
+ logger.debug(`call_cid is not provided, skipping the call.ring notification`);
113
+ return;
114
+ }
115
+ const callingx = (0, _callingx.getCallingxLib)();
116
+ await callingx.checkPermissions();
117
+ if (!callingx.isNotificationsAllowed) {
118
+ logger.debug(`Notification permission not granted, unable to post ${data.type} notifications`);
119
+ return;
120
+ }
121
+ const client = await pushConfig.createStreamVideoClient();
122
+ if (!client) {
123
+ logger.debug(`video client not found, skipping the call.ring notification`);
124
+ return;
125
+ }
126
+ const shouldRejectCallWhenBusy = client['rejectCallWhenBusy'] ?? false;
127
+ if (callingx.hasRegisteredCall() && shouldRejectCallWhenBusy) {
128
+ logger.debug(`registered call found, skipping the call.ring notification`);
129
+ return;
130
+ }
131
+ const asForegroundService = (0, _utils.canListenToWS)();
132
+ const callerName = data.created_by_display_name;
133
+ const hasVideo = data.video === 'true';
132
134
  if (asForegroundService) {
133
135
  // Listen to call events from WS through fg service
134
136
  // note: this will replace the current empty fg service runner
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
137
+ //we need to start service (e.g. by calling display incoming call) and than launch bg task, consider making those steps independent
138
+ callingx.registerBackgroundTask((_, stopTask) => {
139
+ return new Promise(resolve => {
140
+ const finishBackgroundTask = () => {
141
+ callingx.log(`Finishing background task for callCid: ${call_cid}`, 'debug');
142
+ resolve(undefined);
143
+ stopTask();
144
+ };
145
+ (async () => {
146
+ try {
147
+ const _client = await pushConfig.createStreamVideoClient();
148
+ if (!_client) {
149
+ logger.debug(`Closing fg service as there is no client to create from push config`);
150
+ finishBackgroundTask();
151
+ return;
152
+ }
153
+ const callFromPush = await _client.onRingingCall(call_cid);
154
+ if ((0, _utils.shouldCallBeClosed)(callFromPush, data)) {
155
+ logger.debug(`Closing fg service callCid: ${call_cid} shouldCallBeClosed`);
156
+ finishBackgroundTask();
157
+ callingx.log(`Ending call with callCid: ${call_cid} shouldCallBeClosed`, 'debug');
158
+ //TODO: think about sending appropriate reason for end call
159
+ callingx.endCallWithReason(call_cid, 'remote');
160
+ return;
161
+ }
162
+ const unsubscribeFunctions = [];
163
+ // check if service needs to be closed if accept/decline event was done on another device
164
+ const unsubscribe = callFromPush.on('all', event => {
165
+ const _canListenToWS = (0, _utils.canListenToWS)();
166
+ if (!_canListenToWS) {
167
+ logger.debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, {
168
+ event
169
+ });
170
+ unsubscribeFunctions.forEach(fn => fn());
171
+ finishBackgroundTask();
172
+ return;
173
+ }
174
+ if ((0, _utils.shouldCallBeClosed)(callFromPush, data)) {
175
+ logger.debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS} shouldCallBeClosed`, {
176
+ event
177
+ });
178
+ unsubscribeFunctions.forEach(fn => fn());
179
+ finishBackgroundTask();
180
+ //TODO: think about sending appropriate reason for end call
181
+ callingx.endCallWithReason(call_cid, 'rejected');
182
+ }
157
183
  });
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
184
+
185
+ // check if service needs to be closed if call was left
186
+ const stateSubscription = callFromPush.state.callingState$.subscribe(callingState => {
187
+ if (callingState === _videoClient.CallingState.IDLE || callingState === _videoClient.CallingState.LEFT) {
188
+ logger.debug(`Closing fg service from callingState callCid: ${call_cid} callingState: ${callingState}`);
189
+ unsubscribeFunctions.forEach(fn => fn());
190
+
191
+ //TODO: think about sending appropriate reason for end call
192
+ callingx.log(`Ending call with callCid: ${call_cid} callingState: ${callingState}`, 'debug');
193
+ finishBackgroundTask();
194
+ callingx.endCallWithReason(call_cid, 'remote');
195
+ }
166
196
  });
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();
197
+ const endCallSubscription = callingx.addEventListener('endCall', async ({
198
+ callId
199
+ }) => {
200
+ unsubscribeFunctions.forEach(fn => fn());
201
+ try {
202
+ await callFromPush.leave({
203
+ reject: true,
204
+ reason: 'decline'
205
+ });
206
+ } catch (error) {
207
+ logger.error(`Failed to leave call with callCid: ${call_cid} error: ${error}`);
208
+ } finally {
209
+ callingx.log(`Ending call with callCid: ${call_cid} callId: ${callId}`, 'debug');
210
+ finishBackgroundTask();
211
+ callingx.endCallWithReason(callId, 'rejected');
212
+ }
213
+ });
214
+
215
+ //stop background task when app comes to foreground
216
+ const appStateSubscription = _reactNative.AppState.addEventListener('change', nextAppState => {
217
+ const _canListenToWS = (0, _utils.canListenToWS)();
218
+ callingx.log(`AppState changed to: ${nextAppState} for callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, 'debug');
219
+ if (!_canListenToWS) {
220
+ unsubscribeFunctions.forEach(fn => fn());
221
+ finishBackgroundTask();
222
+ return;
223
+ }
224
+ });
225
+ unsubscribeFunctions.push(unsubscribe);
226
+ unsubscribeFunctions.push(() => stateSubscription.unsubscribe());
227
+ unsubscribeFunctions.push(() => endCallSubscription.remove());
228
+ unsubscribeFunctions.push(() => appStateSubscription.remove());
229
+ _constants.pushUnsubscriptionCallbacks.get(call_cid)?.forEach(cb => cb());
230
+ _constants.pushUnsubscriptionCallbacks.set(call_cid, unsubscribeFunctions);
231
+ } catch (error) {
232
+ callingx.log(`Failed to start background task with callCid: ${call_cid} error: ${error}`, 'error');
233
+ finishBackgroundTask();
177
234
  }
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);
235
+ })();
183
236
  });
184
237
  });
185
238
  }
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
- });
239
+ await callingx.displayIncomingCall(call_cid, call_cid, callerName, hasVideo);
240
+ logger.debug(`Displaying incoming call notification with callCid: ${call_cid} asForegroundService: ${asForegroundService}`);
252
241
  if (asForegroundService) {
253
242
  // no need to check if call has be closed as that will be handled by the fg service
254
243
  return;
255
244
  }
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
- }
263
245
  const callFromPush = await client.onRingingCall(call_cid);
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);
246
+ if ((0, _utils.shouldCallBeClosed)(callFromPush, data)) {
247
+ logger.debug(`Removing incoming call notification immediately with callCid: ${call_cid} as it should be closed`);
248
+ //TODO: think about sending appropriate reason for end call
249
+ callingx.endCallWithReason(call_cid, 'remote');
267
250
  }
268
251
  } else {
252
+ const notifeeLib = (0, _libs.getNotifeeLibThrowIfNotInstalledForPush)();
253
+ const notifee = notifeeLib.default;
254
+ const settings = await notifee.getNotificationSettings();
255
+ if (settings.authorizationStatus !== 1) {
256
+ logger.debug(`Notification permission not granted, unable to post ${data.type} notifications`);
257
+ return;
258
+ }
259
+
269
260
  // the other types are call.live_started and call.notification
270
261
  const callChannel = pushConfig.android.callChannel;
271
262
  const callNotificationTextGetters = pushConfig.android.callNotificationTextGetters;
272
263
  if (!callChannel || !callNotificationTextGetters) {
273
- const logger = _videoClient.videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler');
274
264
  logger.debug("Can't show call notification as either or both callChannel and callNotificationTextGetters is not provided");
275
265
  return;
276
266
  }
@@ -285,7 +275,7 @@ const firebaseDataHandler = async data => {
285
275
  const type = data.type;
286
276
  const title = getTitle(type, createdUserName);
287
277
  const body = getBody(type, createdUserName);
288
- _videoClient.videoLoggerSystem.getLogger('firebaseMessagingOnMessageHandler').debug(`Displaying NonRingingPushEvent ${type} notification with title: ${title} body: ${body}`);
278
+ logger.debug(`Displaying NonRingingPushEvent ${type} notification with title: ${title} body: ${body}`);
289
279
  await notifee.displayNotification({
290
280
  title: getTitle(type, createdUserName),
291
281
  body: getBody(type, createdUserName),
@@ -313,8 +303,7 @@ const firebaseDataHandler = async data => {
313
303
  };
314
304
  exports.firebaseDataHandler = firebaseDataHandler;
315
305
  const onAndroidNotifeeEvent = async ({
316
- event,
317
- isBackground
306
+ event
318
307
  }) => {
319
308
  if (_reactNative.Platform.OS !== 'android') return;
320
309
  const {
@@ -322,8 +311,7 @@ const onAndroidNotifeeEvent = async ({
322
311
  detail
323
312
  } = event;
324
313
  const {
325
- notification,
326
- pressAction
314
+ notification
327
315
  } = detail;
328
316
  const notificationId = notification?.id;
329
317
  const data = notification?.data;
@@ -334,53 +322,10 @@ const onAndroidNotifeeEvent = async ({
334
322
 
335
323
  // we can safely cast to string because the data is from "stream.video"
336
324
  const call_cid = data.call_cid;
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
- }
325
+ const notifeeLib = (0, _libs.getNotifeeLibThrowIfNotInstalledForPush)();
326
+ if (type === notifeeLib.EventType.PRESS) {
327
+ _videoClient.videoLoggerSystem.getLogger('onAndroidNotifeeEvent').debug(`onTapNonRingingCallNotification with callCId: ${call_cid}`);
328
+ pushConfig.onTapNonRingingCallNotification?.(call_cid, data.type);
384
329
  }
385
330
  };
386
331
  exports.onAndroidNotifeeEvent = onAndroidNotifeeEvent;