@stream-io/video-react-native-sdk 1.2.16 → 1.3.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 (148) hide show
  1. package/CHANGELOG.md +1609 -0
  2. package/dist/commonjs/components/Call/CallControls/IncomingCallControls.js +2 -1
  3. package/dist/commonjs/components/Call/CallControls/IncomingCallControls.js.map +1 -1
  4. package/dist/commonjs/components/Call/CallControls/OutgoingCallControls.js +4 -3
  5. package/dist/commonjs/components/Call/CallControls/OutgoingCallControls.js.map +1 -1
  6. package/dist/commonjs/components/Call/CallControls/RejectCallButton.js +7 -4
  7. package/dist/commonjs/components/Call/CallControls/RejectCallButton.js.map +1 -1
  8. package/dist/commonjs/hooks/push/useIosCallKeepEventsSetupEffect.js +43 -6
  9. package/dist/commonjs/hooks/push/useIosCallKeepEventsSetupEffect.js.map +1 -1
  10. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +1 -1
  11. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +2 -2
  12. package/dist/commonjs/hooks/push/useProcessPushCallEffect.js +2 -7
  13. package/dist/commonjs/hooks/push/useProcessPushCallEffect.js.map +1 -1
  14. package/dist/commonjs/hooks/push/useProcessPushNonRingingCallEffect.js +3 -3
  15. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js +1 -0
  16. package/dist/commonjs/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  17. package/dist/commonjs/providers/StreamCall.js +1 -1
  18. package/dist/commonjs/utils/StreamVideoRN/index.js +5 -6
  19. package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
  20. package/dist/commonjs/utils/index.js +12 -0
  21. package/dist/commonjs/utils/index.js.map +1 -1
  22. package/dist/commonjs/utils/push/android.js +23 -79
  23. package/dist/commonjs/utils/push/android.js.map +1 -1
  24. package/dist/commonjs/utils/push/index.js +39 -0
  25. package/dist/commonjs/utils/push/index.js.map +1 -0
  26. package/dist/commonjs/utils/push/internal/rxSubjects.js.map +1 -0
  27. package/dist/commonjs/utils/push/internal/utils.js +158 -0
  28. package/dist/commonjs/utils/push/internal/utils.js.map +1 -0
  29. package/dist/commonjs/utils/push/ios.js +43 -84
  30. package/dist/commonjs/utils/push/ios.js.map +1 -1
  31. package/dist/commonjs/utils/push/libs/expoNotifications.js.map +1 -1
  32. package/dist/commonjs/utils/push/libs/index.js +0 -11
  33. package/dist/commonjs/utils/push/libs/index.js.map +1 -1
  34. package/dist/commonjs/utils/push/libs/iosPushNotification.js.map +1 -1
  35. package/dist/commonjs/utils/push/utils.js +29 -150
  36. package/dist/commonjs/utils/push/utils.js.map +1 -1
  37. package/dist/commonjs/version.js +1 -1
  38. package/dist/commonjs/version.js.map +1 -1
  39. package/dist/module/components/Call/CallControls/IncomingCallControls.js +2 -1
  40. package/dist/module/components/Call/CallControls/IncomingCallControls.js.map +1 -1
  41. package/dist/module/components/Call/CallControls/OutgoingCallControls.js +4 -3
  42. package/dist/module/components/Call/CallControls/OutgoingCallControls.js.map +1 -1
  43. package/dist/module/components/Call/CallControls/RejectCallButton.js +7 -4
  44. package/dist/module/components/Call/CallControls/RejectCallButton.js.map +1 -1
  45. package/dist/module/hooks/push/useIosCallKeepEventsSetupEffect.js +41 -4
  46. package/dist/module/hooks/push/useIosCallKeepEventsSetupEffect.js.map +1 -1
  47. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +1 -1
  48. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -1
  49. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +2 -2
  50. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  51. package/dist/module/hooks/push/useProcessPushCallEffect.js +2 -7
  52. package/dist/module/hooks/push/useProcessPushCallEffect.js.map +1 -1
  53. package/dist/module/hooks/push/useProcessPushNonRingingCallEffect.js +3 -3
  54. package/dist/module/hooks/push/useProcessPushNonRingingCallEffect.js.map +1 -1
  55. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js +1 -0
  56. package/dist/module/hooks/useAndroidKeepCallAliveEffect.js.map +1 -1
  57. package/dist/module/providers/StreamCall.js +1 -1
  58. package/dist/module/providers/StreamCall.js.map +1 -1
  59. package/dist/module/utils/StreamVideoRN/index.js +5 -6
  60. package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
  61. package/dist/module/utils/index.js +1 -0
  62. package/dist/module/utils/index.js.map +1 -1
  63. package/dist/module/utils/push/android.js +20 -79
  64. package/dist/module/utils/push/android.js.map +1 -1
  65. package/dist/module/utils/push/index.js +4 -0
  66. package/dist/module/utils/push/index.js.map +1 -0
  67. package/dist/module/utils/push/internal/rxSubjects.js.map +1 -0
  68. package/dist/module/utils/push/internal/utils.js +147 -0
  69. package/dist/module/utils/push/internal/utils.js.map +1 -0
  70. package/dist/module/utils/push/ios.js +40 -81
  71. package/dist/module/utils/push/ios.js.map +1 -1
  72. package/dist/module/utils/push/libs/expoNotifications.js.map +1 -1
  73. package/dist/module/utils/push/libs/index.js +0 -1
  74. package/dist/module/utils/push/libs/index.js.map +1 -1
  75. package/dist/module/utils/push/libs/iosPushNotification.js.map +1 -1
  76. package/dist/module/utils/push/utils.js +25 -144
  77. package/dist/module/utils/push/utils.js.map +1 -1
  78. package/dist/module/version.js +1 -1
  79. package/dist/module/version.js.map +1 -1
  80. package/dist/typescript/components/Call/CallControls/IncomingCallControls.d.ts.map +1 -1
  81. package/dist/typescript/components/Call/CallControls/OutgoingCallControls.d.ts.map +1 -1
  82. package/dist/typescript/components/Call/CallControls/RejectCallButton.d.ts +17 -2
  83. package/dist/typescript/components/Call/CallControls/RejectCallButton.d.ts.map +1 -1
  84. package/dist/typescript/hooks/push/useIosCallKeepEventsSetupEffect.d.ts.map +1 -1
  85. package/dist/typescript/hooks/useAndroidKeepCallAliveEffect.d.ts.map +1 -1
  86. package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
  87. package/dist/typescript/utils/StreamVideoRN/types.d.ts +6 -4
  88. package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
  89. package/dist/typescript/utils/index.d.ts +1 -0
  90. package/dist/typescript/utils/index.d.ts.map +1 -1
  91. package/dist/typescript/utils/push/android.d.ts +12 -2
  92. package/dist/typescript/utils/push/android.d.ts.map +1 -1
  93. package/dist/typescript/utils/push/index.d.ts +4 -0
  94. package/dist/typescript/utils/push/index.d.ts.map +1 -0
  95. package/dist/typescript/utils/push/{rxSubjects.d.ts → internal/rxSubjects.d.ts} +1 -1
  96. package/dist/typescript/utils/push/internal/rxSubjects.d.ts.map +1 -0
  97. package/dist/typescript/utils/push/internal/utils.d.ts +43 -0
  98. package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -0
  99. package/dist/typescript/utils/push/ios.d.ts +8 -3
  100. package/dist/typescript/utils/push/ios.d.ts.map +1 -1
  101. package/dist/typescript/utils/push/libs/expoNotifications.d.ts +2 -0
  102. package/dist/typescript/utils/push/libs/expoNotifications.d.ts.map +1 -1
  103. package/dist/typescript/utils/push/libs/index.d.ts +0 -1
  104. package/dist/typescript/utils/push/libs/index.d.ts.map +1 -1
  105. package/dist/typescript/utils/push/libs/iosPushNotification.d.ts +2 -0
  106. package/dist/typescript/utils/push/libs/iosPushNotification.d.ts.map +1 -1
  107. package/dist/typescript/utils/push/utils.d.ts +14 -42
  108. package/dist/typescript/utils/push/utils.d.ts.map +1 -1
  109. package/dist/typescript/version.d.ts +1 -1
  110. package/dist/typescript/version.d.ts.map +1 -1
  111. package/package.json +6 -11
  112. package/src/components/Call/CallControls/IncomingCallControls.tsx +4 -1
  113. package/src/components/Call/CallControls/OutgoingCallControls.tsx +3 -2
  114. package/src/components/Call/CallControls/RejectCallButton.tsx +19 -3
  115. package/src/hooks/push/useIosCallKeepEventsSetupEffect.ts +62 -6
  116. package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +1 -1
  117. package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +2 -2
  118. package/src/hooks/push/useProcessPushCallEffect.ts +2 -7
  119. package/src/hooks/push/useProcessPushNonRingingCallEffect.ts +3 -3
  120. package/src/hooks/useAndroidKeepCallAliveEffect.ts +1 -0
  121. package/src/providers/StreamCall.tsx +1 -1
  122. package/src/utils/StreamVideoRN/index.ts +11 -6
  123. package/src/utils/StreamVideoRN/types.ts +6 -4
  124. package/src/utils/index.ts +1 -0
  125. package/src/utils/push/android.ts +28 -99
  126. package/src/utils/push/index.ts +3 -0
  127. package/src/utils/push/{rxSubjects.ts → internal/rxSubjects.ts} +1 -1
  128. package/src/utils/push/internal/utils.ts +178 -0
  129. package/src/utils/push/ios.ts +49 -115
  130. package/src/utils/push/libs/expoNotifications.ts +4 -0
  131. package/src/utils/push/libs/index.ts +0 -1
  132. package/src/utils/push/libs/iosPushNotification.ts +4 -0
  133. package/src/utils/push/utils.ts +44 -175
  134. package/src/version.ts +1 -1
  135. package/dist/commonjs/utils/push/libs/expoTaskManager.js +0 -17
  136. package/dist/commonjs/utils/push/libs/expoTaskManager.js.map +0 -1
  137. package/dist/commonjs/utils/push/rxSubjects.js.map +0 -1
  138. package/dist/module/utils/push/libs/expoTaskManager.js +0 -11
  139. package/dist/module/utils/push/libs/expoTaskManager.js.map +0 -1
  140. package/dist/module/utils/push/rxSubjects.js.map +0 -1
  141. package/dist/typescript/utils/push/libs/expoTaskManager.d.ts +0 -3
  142. package/dist/typescript/utils/push/libs/expoTaskManager.d.ts.map +0 -1
  143. package/dist/typescript/utils/push/rxSubjects.d.ts.map +0 -1
  144. package/ios/StreamVideoReactNative.xcodeproj/project.xcworkspace/xcuserdata/santhoshvaiyapuri.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  145. package/ios/StreamVideoReactNative.xcodeproj/xcuserdata/santhoshvaiyapuri.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  146. package/src/utils/push/libs/expoTaskManager.ts +0 -16
  147. /package/dist/commonjs/utils/push/{rxSubjects.js → internal/rxSubjects.js} +0 -0
  148. /package/dist/module/utils/push/{rxSubjects.js → internal/rxSubjects.js} +0 -0
@@ -1,43 +1,15 @@
1
- import { Call, StreamVideoClient } from '@stream-io/video-client';
2
- import type { NonRingingPushEvent, StreamVideoConfig } from '../StreamVideoRN/types';
3
- type PushConfig = NonNullable<StreamVideoConfig['push']>;
4
- type CanAddPushWSSubscriptionsRef = {
5
- current: boolean;
6
- };
7
- /**
8
- * This function is used to check if the call should be ended based on the push notification
9
- * Useful for callkeep management to end the call if necessary (with reportEndCallWithUUID)
10
- */
11
- export declare const shouldCallBeEnded: (callFromPush: Call, created_by_id: string | undefined, receiver_id: string | undefined) => {
12
- mustEndCall: boolean;
13
- callkeepReason: number;
14
- };
15
- export declare const processCallFromPushInBackground: (pushConfig: PushConfig, call_cid: string, action: Parameters<typeof processCallFromPush>[2]) => Promise<void>;
16
- /**
17
- * This function is used process the call from push notifications due to incoming call
18
- * It does the following steps:
19
- * 1. Get the call from the client if present or create a new call
20
- * 2. Fetch the latest state of the call from the server if its not already in ringing state
21
- * 3. Join or leave the call based on the user's action.
22
- */
23
- export declare const processCallFromPush: (client: StreamVideoClient, call_cid: string, action: "accept" | "decline" | "pressed" | "backgroundDelivered", pushConfig: PushConfig) => Promise<void>;
24
- /**
25
- * This function is used process the call from push notifications due to non ringing calls
26
- * It does the following steps:
27
- * 1. Get the call from the client if present or create a new call
28
- * 2. Fetch the latest state of the call from the server if its not already in ringing state
29
- * 3. Call all the callbacks to inform the app about the call
30
- */
31
- export declare const processNonIncomingCallFromPush: (client: StreamVideoClient, call_cid: string, nonRingingNotificationType: NonRingingPushEvent) => Promise<void>;
32
- /**
33
- * This function is used to clear all the push related WS subscriptions
34
- * note: events are subscribed in push for accept/decline through WS
35
- */
36
- export declare const clearPushWSEventSubscriptions: () => void;
37
- /**
38
- * This ref is used to check if the push WS subscriptions can be added
39
- * It is used to avoid adding the push WS subscriptions when the client is connected to WS in the foreground
40
- */
41
- export declare const canAddPushWSSubscriptionsRef: CanAddPushWSSubscriptionsRef;
42
- export {};
1
+ import { Event } from '@notifee/react-native';
2
+ import { FirebaseMessagingTypes } from './libs/firebaseMessaging';
3
+ import { ExpoNotification } from './libs/expoNotifications';
4
+ import { NonRingingPushEvent } from '../StreamVideoRN/types';
5
+ import { PushNotificationiOSType } from './libs/iosPushNotification';
6
+ export type StreamPushPayload = {
7
+ call_cid: string;
8
+ type: 'call.ring' | NonRingingPushEvent;
9
+ sender: string;
10
+ } | undefined;
11
+ export declare function isFirebaseStreamVideoMessage(message: FirebaseMessagingTypes.RemoteMessage): boolean;
12
+ export declare function isNotifeeStreamVideoEvent(event: Event): boolean;
13
+ export declare function isExpoNotificationStreamVideoEvent(event: ExpoNotification): boolean | undefined;
14
+ export declare function isPushNotificationiOSStreamVideoEvent(notification: PushNotificationiOSType): boolean;
43
15
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/push/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAGJ,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAIhC,KAAK,UAAU,GAAG,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;AAEzD,KAAK,4BAA4B,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,iBACd,IAAI,iBACH,MAAM,GAAG,SAAS,eACpB,MAAM,GAAG,SAAS;;;CAmChC,CAAC;AAMF,eAAO,MAAM,+BAA+B,eAC9B,UAAU,YACZ,MAAM,UACR,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,kBAelD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,WACtB,iBAAiB,YACf,MAAM,UACR,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,qBAAqB,cACpD,UAAU,kBA4BvB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,WACjC,iBAAiB,YACf,MAAM,8BACY,mBAAmB,kBAmBhD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,6BAA6B,YAQzC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,4BAE1C,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/push/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE,MAAM,MAAM,iBAAiB,GACzB;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,WAAW,GAAG,mBAAmB,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;CAChB,GACD,SAAS,CAAC;AAEd,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,sBAAsB,CAAC,aAAa,WAG9C;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,KAAK,WAIrD;AAED,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,gBAAgB,uBAYzE;AAED,wBAAgB,qCAAqC,CACnD,YAAY,EAAE,uBAAuB,WAKtC"}
@@ -1,2 +1,2 @@
1
- export declare const version = "1.2.15";
1
+ export declare const version = "1.3.1";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-react-native-sdk",
3
- "version": "1.2.16",
3
+ "version": "1.3.1",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "module": "dist/module/index.js",
@@ -65,7 +65,6 @@
65
65
  "expo": ">=47.0.0",
66
66
  "expo-build-properties": "*",
67
67
  "expo-notifications": "*",
68
- "expo-task-manager": "*",
69
68
  "react": ">=17.0.0",
70
69
  "react-native": ">=0.67.0",
71
70
  "react-native-callkeep": ">=4.3.11",
@@ -100,9 +99,6 @@
100
99
  "expo-notifications": {
101
100
  "optional": true
102
101
  },
103
- "expo-task-manager": {
104
- "optional": true
105
- },
106
102
  "react-native-callkeep": {
107
103
  "optional": true
108
104
  },
@@ -122,11 +118,11 @@
122
118
  "@notifee/react-native": "7.8.0",
123
119
  "@react-native-community/netinfo": "9.3.9",
124
120
  "@react-native-community/push-notification-ios": "1.11.0",
125
- "@react-native-firebase/app": "17.5.0",
126
- "@react-native-firebase/messaging": "17.5.0",
121
+ "@react-native-firebase/app": "19.2.2",
122
+ "@react-native-firebase/messaging": "19.2.2",
127
123
  "@react-native/eslint-config": "^0.74.84",
128
124
  "@stream-io/react-native-webrtc": "118.1.0",
129
- "@stream-io/video-filters-react-native": "workspace:^",
125
+ "@stream-io/video-filters-react-native": "^0.2.4",
130
126
  "@testing-library/jest-native": "^5.4.2",
131
127
  "@testing-library/react-native": "^12.1.2",
132
128
  "@tsconfig/node14": "14.1.0",
@@ -139,8 +135,7 @@
139
135
  "expo": "50.0.19",
140
136
  "expo-build-properties": "^0.12.3",
141
137
  "expo-modules-core": "1.12.16",
142
- "expo-notifications": "~0.27.8",
143
- "expo-task-manager": "~11.7.3",
138
+ "expo-notifications": "~0.28.18",
144
139
  "jest": "^29.7.0",
145
140
  "react-native": "0.71.8",
146
141
  "react-native-builder-bob": "^0.23.2",
@@ -168,4 +163,4 @@
168
163
  "typescript"
169
164
  ]
170
165
  }
171
- }
166
+ }
@@ -28,7 +28,10 @@ export const IncomingCallControls = ({
28
28
  } = useTheme();
29
29
  return (
30
30
  <View style={[styles.buttonGroup, incomingCall.buttonGroup]}>
31
- <RejectCallButton onPressHandler={onRejectCallHandler} />
31
+ <RejectCallButton
32
+ onPressHandler={onRejectCallHandler}
33
+ rejectReason="decline"
34
+ />
32
35
  <ToggleVideoPreviewButton />
33
36
  <AcceptCallButton onPressHandler={onAcceptCallHandler} />
34
37
  </View>
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { StyleSheet, View } from 'react-native';
3
3
  import { useTheme } from '../../../contexts';
4
- import { HangUpCallButton } from './HangupCallButton';
5
4
  import { ToggleAudioPreviewButton } from './ToggleAudioPreviewButton';
6
5
  import { ToggleVideoPreviewButton } from './ToggleVideoPreviewButton';
6
+ import { RejectCallButton } from './RejectCallButton';
7
7
 
8
8
  /**
9
9
  * Props for the OutgoingCallControls Component.
@@ -32,9 +32,10 @@ export const OutgoingCallControls = ({
32
32
  <ToggleAudioPreviewButton />
33
33
  <ToggleVideoPreviewButton />
34
34
  </View>
35
- <HangUpCallButton
35
+ <RejectCallButton
36
36
  onPressHandler={onHangupCallHandler}
37
37
  size={buttonSizes.md}
38
+ rejectReason="cancel"
38
39
  />
39
40
  </View>
40
41
  );
@@ -20,16 +20,32 @@ type RejectCallButtonProps = {
20
20
  * Note: If the `onPressHandler` is passed this handler will not be executed.
21
21
  */
22
22
  onRejectCallHandler?: () => void;
23
+ /**
24
+ * Sets the height, width and border-radius (half the value) of the button.
25
+ */
26
+ size?: React.ComponentProps<typeof CallControlsButton>['size'];
27
+ /**
28
+ * Optional: Reason for rejecting the call.
29
+ * Pass a predefined or a custom reason.
30
+ * There are four predefined reasons for rejecting the call:
31
+ - `busy` - when the callee is busy and cannot accept the call.
32
+ - `decline` - when the callee intentionally declines the call.
33
+ - `cancel` - when the caller cancels the call.
34
+ - `timeout` - when the **caller** or **callee** rejects the call after `auto_cancel_timeout_ms` or `incoming_call_timeout_ms` accordingly.
35
+ */
36
+ rejectReason?: string;
23
37
  };
24
38
 
25
39
  /**
26
40
  * Button to reject a call.
27
41
  *
28
- * Mostly calls call.leave({ reject: true }) internally.
42
+ * Calls call.leave({ reject: true, reason: `OPTIONAL-REASON` }) internally.
29
43
  */
30
44
  export const RejectCallButton = ({
31
45
  onPressHandler,
32
46
  onRejectCallHandler,
47
+ size,
48
+ rejectReason,
33
49
  }: RejectCallButtonProps) => {
34
50
  const call = useCall();
35
51
  const { useCallCallingState } = useCallStateHooks();
@@ -50,7 +66,7 @@ export const RejectCallButton = ({
50
66
  if (callingState === CallingState.LEFT) {
51
67
  return;
52
68
  }
53
- await call?.leave({ reject: true });
69
+ await call?.leave({ reject: true, reason: rejectReason });
54
70
  if (onRejectCallHandler) {
55
71
  onRejectCallHandler();
56
72
  }
@@ -64,7 +80,7 @@ export const RejectCallButton = ({
64
80
  <CallControlsButton
65
81
  onPress={rejectCallHandler}
66
82
  color={colors.error}
67
- size={buttonSizes.lg}
83
+ size={size ?? buttonSizes.lg}
68
84
  // TODO: check what to do about this random style prop
69
85
  // svgContainerStyle={theme.icon.lg}
70
86
  style={rejectCallButton}
@@ -2,16 +2,23 @@ import { useEffect } from 'react';
2
2
  import {
3
3
  voipCallkeepCallOnForegroundMap$,
4
4
  voipPushNotificationCallCId$,
5
- } from '../../utils/push/rxSubjects';
5
+ } from '../../utils/push/internal/rxSubjects';
6
6
  import { RxUtils } from '@stream-io/video-client';
7
- import {
8
- iosCallkeepAcceptCall,
9
- iosCallkeepRejectCall,
10
- } from '../../utils/push/ios';
11
7
  import { getCallKeepLib } from '../../utils/push/libs';
12
- import { StreamVideoRN } from '../../utils';
8
+ import { StreamVideoRN } from '../../utils/StreamVideoRN';
9
+ import type { StreamVideoConfig } from '../../utils/StreamVideoRN/types';
10
+ import {
11
+ clearPushWSEventSubscriptions,
12
+ processCallFromPushInBackground,
13
+ } from '../../utils/push/internal/utils';
14
+ import {
15
+ pushAcceptedIncomingCallCId$,
16
+ voipCallkeepAcceptedCallOnNativeDialerMap$,
17
+ } from '../../utils/push/internal/rxSubjects';
13
18
  import { Platform } from 'react-native';
14
19
 
20
+ type PushConfig = NonNullable<StreamVideoConfig['push']>;
21
+
15
22
  /**
16
23
  * This hook is used to listen to callkeep events and do the necessary actions
17
24
  */
@@ -62,3 +69,52 @@ export const useIosCallKeepEventsSetupEffect = () => {
62
69
  };
63
70
  }, []);
64
71
  };
72
+
73
+ const iosCallkeepAcceptCall = (
74
+ call_cid: string | undefined,
75
+ callUUIDFromCallkeep: string
76
+ ) => {
77
+ if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
78
+ return;
79
+ }
80
+ clearPushWSEventSubscriptions();
81
+ // to call end callkeep later if ended in app and not through callkeep
82
+ voipCallkeepAcceptedCallOnNativeDialerMap$.next({
83
+ uuid: callUUIDFromCallkeep,
84
+ cid: call_cid,
85
+ });
86
+ // to process the call in the app
87
+ pushAcceptedIncomingCallCId$.next(call_cid);
88
+ // no need to keep these references anymore
89
+ voipCallkeepCallOnForegroundMap$.next(undefined);
90
+ };
91
+
92
+ const iosCallkeepRejectCall = async (
93
+ call_cid: string | undefined,
94
+ callUUIDFromCallkeep: string,
95
+ pushConfig: PushConfig
96
+ ) => {
97
+ if (!shouldProcessCallFromCallkeep(call_cid, callUUIDFromCallkeep)) {
98
+ return;
99
+ }
100
+ clearPushWSEventSubscriptions();
101
+ // no need to keep these references anymore
102
+ voipCallkeepAcceptedCallOnNativeDialerMap$.next(undefined);
103
+ voipCallkeepCallOnForegroundMap$.next(undefined);
104
+ voipPushNotificationCallCId$.next(undefined);
105
+ await processCallFromPushInBackground(pushConfig, call_cid, 'decline');
106
+ };
107
+
108
+ /**
109
+ * Helper function to determine if the answer/end call event from callkeep must be processed
110
+ * Just checks if we have a valid call_cid and acts as a type guard for call_cid
111
+ */
112
+ const shouldProcessCallFromCallkeep = (
113
+ call_cid: string | undefined,
114
+ callUUIDFromCallkeep: string
115
+ ): call_cid is string => {
116
+ if (!call_cid || !callUUIDFromCallkeep) {
117
+ return false;
118
+ }
119
+ return true;
120
+ };
@@ -7,7 +7,7 @@ import { getCallKeepLib } from '../../utils/push/libs';
7
7
  import {
8
8
  voipCallkeepAcceptedCallOnNativeDialerMap$,
9
9
  voipCallkeepCallOnForegroundMap$,
10
- } from '../../utils/push/rxSubjects';
10
+ } from '../../utils/push/internal/rxSubjects';
11
11
 
12
12
  const isNonActiveCallingState = (callingState: CallingState) => {
13
13
  return (
@@ -12,11 +12,11 @@ import { NativeModules } from 'react-native';
12
12
  import {
13
13
  canAddPushWSSubscriptionsRef,
14
14
  shouldCallBeEnded,
15
- } from '../../utils/push/utils';
15
+ } from '../../utils/push/internal/utils';
16
16
  import {
17
17
  pushUnsubscriptionCallbacks$,
18
18
  voipPushNotificationCallCId$,
19
- } from '../../utils/push/rxSubjects';
19
+ } from '../../utils/push/internal/rxSubjects';
20
20
  import { RxUtils, getLogger } from '@stream-io/video-client';
21
21
 
22
22
  let lastVoipToken = { token: '', userId: '' };
@@ -3,7 +3,7 @@ import {
3
3
  pushAndroidBackgroundDeliveredIncomingCallCId$,
4
4
  pushRejectedIncomingCallCId$,
5
5
  pushTappedIncomingCallCId$,
6
- } from '../../utils/push/rxSubjects';
6
+ } from '../../utils/push/internal/rxSubjects';
7
7
  import { useEffect } from 'react';
8
8
  import { StreamVideoRN } from '../../utils';
9
9
  import {
@@ -12,7 +12,7 @@ import {
12
12
  } from '@stream-io/video-react-bindings';
13
13
  import { BehaviorSubject } from 'rxjs';
14
14
  import { filter } from 'rxjs/operators';
15
- import { processCallFromPush } from '../../utils/push/utils';
15
+ import { processCallFromPush } from '../../utils/push/internal/utils';
16
16
  import { StreamVideoClient } from '@stream-io/video-client';
17
17
  import type { StreamVideoConfig } from '../../utils/StreamVideoRN/types';
18
18
 
@@ -92,11 +92,6 @@ const createCallSubscription = (
92
92
  .pipe(filter(cidIsNotUndefined))
93
93
  .subscribe(async (callCId) => {
94
94
  await processCallFromPush(client, callCId, action, pushConfig);
95
- if (action === 'accept') {
96
- pushConfig.navigateAcceptCall();
97
- } else if (action === 'pressed' || action === 'backgroundDelivered') {
98
- pushConfig.navigateToIncomingCall();
99
- }
100
95
  behaviourSubjectWithCallCid.next(undefined); // remove the current call id to avoid processing again
101
96
  });
102
97
  };
@@ -1,4 +1,4 @@
1
- import { pushNonRingingCallData$ } from '../../utils/push/rxSubjects';
1
+ import { pushNonRingingCallData$ } from '../../utils/push/internal/rxSubjects';
2
2
  import { useEffect } from 'react';
3
3
  import { StreamVideoRN } from '../../utils';
4
4
  import {
@@ -6,7 +6,7 @@ import {
6
6
  useStreamVideoClient,
7
7
  } from '@stream-io/video-react-bindings';
8
8
  import { filter } from 'rxjs/operators';
9
- import { processNonIncomingCallFromPush } from '../../utils/push/utils';
9
+ import { processNonIncomingCallFromPush } from '../../utils/push/internal/utils';
10
10
 
11
11
  /**
12
12
  * This hook is used to process the non ringing call data via push notifications using the relevant rxjs subject
@@ -16,7 +16,7 @@ import { processNonIncomingCallFromPush } from '../../utils/push/utils';
16
16
  export const useProcessPushNonRingingCallEffect = () => {
17
17
  const client = useStreamVideoClient();
18
18
  const connectedUserId = useConnectedUser()?.id;
19
- // The Effect to join/reject call automatically when incoming call was received and processed from push notification
19
+ // The Effect to automatically add the non ringing call to our low level client state
20
20
  useEffect(() => {
21
21
  const pushConfig = StreamVideoRN.getConfig().push;
22
22
  if (!pushConfig || !client || !connectedUserId) {
@@ -37,6 +37,7 @@ async function startForegroundService(call_cid: string) {
37
37
  );
38
38
  return;
39
39
  }
40
+ // channel id is not required for notifee as its only used on android 7 and below here
40
41
  await notifeeLib.default.displayNotification({
41
42
  id: call_cid,
42
43
  title,
@@ -5,7 +5,7 @@ import { useIosCallkeepWithCallingStateEffect } from '../hooks/push/useIosCallke
5
5
  import {
6
6
  canAddPushWSSubscriptionsRef,
7
7
  clearPushWSEventSubscriptions,
8
- } from '../utils/push/utils';
8
+ } from '../utils/push/internal/utils';
9
9
  import { useAndroidKeepCallAliveEffect } from '../hooks/useAndroidKeepCallAliveEffect';
10
10
  import { AppState, NativeModules, Platform } from 'react-native';
11
11
  import { shouldDisableIOSLocalVideoOnBackgroundRef } from '../utils/internal/shouldDisableIOSLocalVideoOnBackground';
@@ -1,7 +1,5 @@
1
- import { setupFirebaseHandlerAndroid } from '../push/android';
2
1
  import { StreamVideoConfig } from './types';
3
2
  import pushLogoutCallbacks from '../internal/pushLogoutCallback';
4
- import { setupRemoteNotificationsHandleriOS } from '../push/ios';
5
3
  import newNotificationCallbacks, {
6
4
  NewCallNotificationCallback,
7
5
  } from '../internal/newNotificationCallbacks';
@@ -66,11 +64,18 @@ export class StreamVideoRN {
66
64
  // Ignoring this config as push config was already set
67
65
  return;
68
66
  }
67
+ if (
68
+ __DEV__ &&
69
+ (pushConfig.navigateAcceptCall || pushConfig.navigateToIncomingCall)
70
+ ) {
71
+ throw new Error(
72
+ `Support for navigateAcceptCall or navigateToIncomingCall in pushConfig has been removed.
73
+ Please watch for incoming and outgoing calls in the root component of your app.
74
+ Please see https://getstream.io/video/docs/react-native/advanced/ringing-calls/#watch-for-incoming-and-outgoing-calls for more information.`
75
+ );
76
+ }
77
+
69
78
  this.config.push = pushConfig;
70
- // After getting the config we should setup callkeep events, firebase handler asap to handle incoming calls from a dead state
71
- setupFirebaseHandlerAndroid(pushConfig);
72
- // setup ios handler for non-voip push notifications asap
73
- setupRemoteNotificationsHandleriOS(pushConfig);
74
79
  }
75
80
 
76
81
  static getConfig() {
@@ -107,10 +107,12 @@ export type StreamVideoConfig = {
107
107
  * }
108
108
  */
109
109
  createStreamVideoClient: () => Promise<StreamVideoClient | undefined>;
110
- /** The callback that is called when a call is accepted, used for navigation */
111
- navigateAcceptCall: () => void;
112
- /** The callback that is called when a push notification is tapped but user did not press accept or decline, used for navigation */
113
- navigateToIncomingCall: () => void;
110
+ /** @deprecated This method will be removed in the future. Please watch for incoming and outgoing calls in the root component of your app.
111
+ Please see https://getstream.io/video/docs/react-native/advanced/ringing-calls/#watch-for-incoming-and-outgoing-calls for more information */
112
+ navigateAcceptCall?: () => void;
113
+ /** @deprecated This method will be removed in the future. Please watch for incoming and outgoing calls in the root component of your app.
114
+ Please see https://getstream.io/video/docs/react-native/advanced/ringing-calls/#watch-for-incoming-and-outgoing-calls for more information */
115
+ navigateToIncomingCall?: () => void;
114
116
  /** Callback that is called when a non ringing push notification was tapped */
115
117
  onTapNonRingingCallNotification?: (
116
118
  call_cid: string,
@@ -38,5 +38,6 @@ export const getInitialsOfName = (name: string) => {
38
38
  return initials;
39
39
  };
40
40
 
41
+ export * from './push/index';
41
42
  export * from './enterPiPAndroid';
42
43
  export * from './StreamVideoRN';
@@ -1,4 +1,3 @@
1
- import { FirebaseMessagingTypes } from '@react-native-firebase/messaging';
2
1
  import {
3
2
  Call,
4
3
  RxUtils,
@@ -12,11 +11,10 @@ import type {
12
11
  } from '../StreamVideoRN/types';
13
12
  import {
14
13
  getFirebaseMessagingLib,
15
- getFirebaseMessagingLibNoThrow,
16
14
  getExpoNotificationsLib,
17
- getExpoTaskManagerLib,
18
15
  getNotifeeLibThrowIfNotInstalledForPush,
19
16
  NotifeeLib,
17
+ FirebaseMessagingTypes,
20
18
  } from './libs';
21
19
  import {
22
20
  pushAcceptedIncomingCallCId$,
@@ -25,15 +23,16 @@ import {
25
23
  pushNonRingingCallData$,
26
24
  pushUnsubscriptionCallbacks$,
27
25
  pushAndroidBackgroundDeliveredIncomingCallCId$,
28
- } from './rxSubjects';
26
+ } from './internal/rxSubjects';
29
27
  import {
30
28
  canAddPushWSSubscriptionsRef,
31
29
  clearPushWSEventSubscriptions,
32
30
  processCallFromPushInBackground,
33
31
  shouldCallBeEnded,
34
- } from './utils';
32
+ } from './internal/utils';
35
33
  import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
36
34
  import { getAndroidDefaultRingtoneUrl } from '../getAndroidDefaultRingtoneUrl';
35
+ import { StreamVideoRN } from '../StreamVideoRN';
37
36
 
38
37
  const ACCEPT_CALL_ACTION_ID = 'accept';
39
38
  const DECLINE_CALL_ACTION_ID = 'decline';
@@ -48,89 +47,6 @@ type Event = Parameters<onBackgroundEventFunctionParams>[0];
48
47
 
49
48
  let lastFirebaseToken = { token: '', userId: '' };
50
49
 
51
- // EventType = NotifeeLib['EventType'];
52
-
53
- /** Setup Firebase push message handler **/
54
- export function setupFirebaseHandlerAndroid(pushConfig: PushConfig) {
55
- if (Platform.OS !== 'android') {
56
- return;
57
- }
58
- if (pushConfig.isExpo) {
59
- const messaging = getFirebaseMessagingLibNoThrow(true);
60
- if (messaging) {
61
- // handles on app killed state in expo, expo-notifications cannot handle that
62
- messaging().setBackgroundMessageHandler(
63
- async (msg) =>
64
- await firebaseMessagingOnMessageHandler(msg.data, pushConfig)
65
- );
66
- messaging().onMessage((msg) =>
67
- firebaseMessagingOnMessageHandler(msg.data, pushConfig)
68
- ); // this is to listen to foreground messages, which we dont need for now
69
- } else {
70
- const Notifications = getExpoNotificationsLib();
71
- const TaskManager = getExpoTaskManagerLib();
72
- const BACKGROUND_NOTIFICATION_TASK =
73
- 'STREAM-VIDEO-SDK-INTERNAL-BACKGROUND-NOTIFICATION-TASK';
74
-
75
- TaskManager.defineTask(
76
- BACKGROUND_NOTIFICATION_TASK,
77
- ({ data, error }) => {
78
- if (error) {
79
- return;
80
- }
81
- // @ts-ignore
82
- const dataToProcess = data.notification?.data;
83
- firebaseMessagingOnMessageHandler(dataToProcess, pushConfig);
84
- }
85
- );
86
- // background handler (does not handle on app killed state)
87
- Notifications.registerTaskAsync(BACKGROUND_NOTIFICATION_TASK);
88
- // foreground handler
89
- Notifications.setNotificationHandler({
90
- handleNotification: async (notification) => {
91
- // @ts-ignore
92
- const trigger = notification?.request?.trigger;
93
- if (trigger.type === 'push') {
94
- const data = trigger?.remoteMessage?.data;
95
- if (data?.sender === 'stream.video') {
96
- await firebaseMessagingOnMessageHandler(data, pushConfig);
97
- return {
98
- shouldShowAlert: false,
99
- shouldPlaySound: false,
100
- shouldSetBadge: false,
101
- };
102
- }
103
- }
104
- return {
105
- shouldShowAlert: true,
106
- shouldPlaySound: false,
107
- shouldSetBadge: false,
108
- };
109
- },
110
- });
111
- }
112
- } else {
113
- const messaging = getFirebaseMessagingLib();
114
- messaging().setBackgroundMessageHandler(
115
- async (msg) =>
116
- await firebaseMessagingOnMessageHandler(msg.data, pushConfig)
117
- );
118
- messaging().onMessage((msg) =>
119
- firebaseMessagingOnMessageHandler(msg.data, pushConfig)
120
- ); // this is to listen to foreground messages, which we dont need for now
121
- }
122
-
123
- // the notification tap handlers are always registered with notifee for both expo and non-expo in android
124
- const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
125
- const notifee = notifeeLib.default;
126
- notifee.onBackgroundEvent(async (event) => {
127
- await onNotifeeEvent(event, pushConfig, true);
128
- });
129
- notifee.onForegroundEvent((event) => {
130
- onNotifeeEvent(event, pushConfig, false);
131
- });
132
- }
133
-
134
50
  /** Send token to stream, create notification channel, */
135
51
  export async function initAndroidPushToken(
136
52
  client: StreamVideoClient,
@@ -184,10 +100,14 @@ export async function initAndroidPushToken(
184
100
  }
185
101
  }
186
102
 
187
- const firebaseMessagingOnMessageHandler = async (
188
- data: FirebaseMessagingTypes.RemoteMessage['data'],
189
- pushConfig: PushConfig
103
+ /**
104
+ * Creates notification from the push message data.
105
+ * For Ringing and Non-Ringing calls.
106
+ */
107
+ export const firebaseDataHandler = async (
108
+ data: FirebaseMessagingTypes.RemoteMessage['data']
190
109
  ) => {
110
+ if (Platform.OS !== 'android') return;
191
111
  /* Example data from firebase
192
112
  "message": {
193
113
  "data": {
@@ -203,7 +123,8 @@ const firebaseMessagingOnMessageHandler = async (
203
123
  // other stuff
204
124
  }
205
125
  */
206
- if (!data || data.sender !== 'stream.video') {
126
+ const pushConfig = StreamVideoRN.getConfig().push;
127
+ if (!pushConfig || !data || data.sender !== 'stream.video') {
207
128
  return;
208
129
  }
209
130
 
@@ -377,16 +298,25 @@ const firebaseMessagingOnMessageHandler = async (
377
298
  }
378
299
  };
379
300
 
380
- const onNotifeeEvent = async (
381
- event: Event,
382
- pushConfig: PushConfig,
383
- isBackground: boolean
384
- ) => {
301
+ export const onAndroidNotifeeEvent = async ({
302
+ event,
303
+ isBackground,
304
+ }: {
305
+ event: Event;
306
+ isBackground: boolean;
307
+ }) => {
308
+ if (Platform.OS !== 'android') return;
385
309
  const { type, detail } = event;
386
310
  const { notification, pressAction } = detail;
387
311
  const notificationId = notification?.id;
388
312
  const data = notification?.data;
389
- if (!data || !notificationId || data.sender !== 'stream.video') {
313
+ const pushConfig = StreamVideoRN.getConfig().push;
314
+ if (
315
+ !pushConfig ||
316
+ !data ||
317
+ !notificationId ||
318
+ data.sender !== 'stream.video'
319
+ ) {
390
320
  return;
391
321
  }
392
322
 
@@ -443,7 +373,6 @@ const onNotifeeEvent = async (
443
373
  } else {
444
374
  const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
445
375
  if (type === notifeeLib.EventType.PRESS) {
446
- pushTappedIncomingCallCId$.next(call_cid);
447
376
  pushConfig.onTapNonRingingCallNotification?.(
448
377
  call_cid,
449
378
  data.type as NonRingingPushEvent
@@ -0,0 +1,3 @@
1
+ export * from './android';
2
+ export * from './ios';
3
+ export * from './utils';