@stream-io/video-react-native-sdk 1.10.16 → 1.10.17

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 (57) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/commonjs/hooks/push/useInitAndroidTokenAndRest.js +3 -0
  3. package/dist/commonjs/hooks/push/useInitAndroidTokenAndRest.js.map +1 -1
  4. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js +15 -3
  5. package/dist/commonjs/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -1
  6. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js +11 -1
  7. package/dist/commonjs/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  8. package/dist/commonjs/utils/push/android.js +22 -15
  9. package/dist/commonjs/utils/push/android.js.map +1 -1
  10. package/dist/commonjs/utils/push/libs/expoNotifications.js +9 -1
  11. package/dist/commonjs/utils/push/libs/expoNotifications.js.map +1 -1
  12. package/dist/commonjs/utils/push/libs/firebaseMessaging/index.js +1 -1
  13. package/dist/commonjs/utils/push/libs/firebaseMessaging/index.js.map +1 -1
  14. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js +5 -0
  15. package/dist/commonjs/utils/push/setupIosCallKeepEvents.js.map +1 -1
  16. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +5 -0
  17. package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
  18. package/dist/commonjs/version.js +1 -1
  19. package/dist/module/hooks/push/useInitAndroidTokenAndRest.js +3 -0
  20. package/dist/module/hooks/push/useInitAndroidTokenAndRest.js.map +1 -1
  21. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js +15 -3
  22. package/dist/module/hooks/push/useIosCallkeepWithCallingStateEffect.js.map +1 -1
  23. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js +11 -1
  24. package/dist/module/hooks/push/useIosVoipPushEventsSetupEffect.js.map +1 -1
  25. package/dist/module/utils/push/android.js +23 -16
  26. package/dist/module/utils/push/android.js.map +1 -1
  27. package/dist/module/utils/push/libs/expoNotifications.js +8 -1
  28. package/dist/module/utils/push/libs/expoNotifications.js.map +1 -1
  29. package/dist/module/utils/push/libs/firebaseMessaging/index.js +1 -1
  30. package/dist/module/utils/push/libs/firebaseMessaging/index.js.map +1 -1
  31. package/dist/module/utils/push/setupIosCallKeepEvents.js +5 -0
  32. package/dist/module/utils/push/setupIosCallKeepEvents.js.map +1 -1
  33. package/dist/module/utils/push/setupIosVoipPushEvents.js +5 -0
  34. package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
  35. package/dist/module/version.js +1 -1
  36. package/dist/typescript/hooks/push/useInitAndroidTokenAndRest.d.ts.map +1 -1
  37. package/dist/typescript/hooks/push/useIosCallkeepWithCallingStateEffect.d.ts.map +1 -1
  38. package/dist/typescript/hooks/push/useIosVoipPushEventsSetupEffect.d.ts.map +1 -1
  39. package/dist/typescript/utils/StreamVideoRN/types.d.ts +2 -2
  40. package/dist/typescript/utils/push/android.d.ts +1 -1
  41. package/dist/typescript/utils/push/android.d.ts.map +1 -1
  42. package/dist/typescript/utils/push/libs/expoNotifications.d.ts +1 -0
  43. package/dist/typescript/utils/push/libs/expoNotifications.d.ts.map +1 -1
  44. package/dist/typescript/utils/push/setupIosCallKeepEvents.d.ts.map +1 -1
  45. package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
  46. package/dist/typescript/version.d.ts +1 -1
  47. package/package.json +3 -3
  48. package/src/hooks/push/useInitAndroidTokenAndRest.ts +7 -0
  49. package/src/hooks/push/useIosCallkeepWithCallingStateEffect.ts +30 -3
  50. package/src/hooks/push/useIosVoipPushEventsSetupEffect.ts +21 -1
  51. package/src/utils/StreamVideoRN/types.ts +2 -2
  52. package/src/utils/push/android.ts +32 -21
  53. package/src/utils/push/libs/expoNotifications.ts +12 -1
  54. package/src/utils/push/libs/firebaseMessaging/index.ts +1 -1
  55. package/src/utils/push/setupIosCallKeepEvents.ts +8 -0
  56. package/src/utils/push/setupIosVoipPushEvents.ts +8 -0
  57. package/src/version.ts +1 -1
@@ -12,7 +12,9 @@ import type {
12
12
  } from '../StreamVideoRN/types';
13
13
  import {
14
14
  getFirebaseMessagingLib,
15
+ getFirebaseMessagingLibNoThrow,
15
16
  getExpoNotificationsLib,
17
+ getExpoNotificationsLibNoThrow,
16
18
  getNotifeeLibThrowIfNotInstalledForPush,
17
19
  type NotifeeLib,
18
20
  type FirebaseMessagingTypes,
@@ -49,7 +51,7 @@ type Event = Parameters<onBackgroundEventFunctionParams>[0];
49
51
 
50
52
  let lastFirebaseToken = { token: '', userId: '' };
51
53
 
52
- /** Send token to stream, create notification channel, */
54
+ /** Send token to stream */
53
55
  export async function initAndroidPushToken(
54
56
  client: StreamVideoClient,
55
57
  pushConfig: PushConfig,
@@ -58,13 +60,14 @@ export async function initAndroidPushToken(
58
60
  if (Platform.OS !== 'android' || !pushConfig.android.pushProviderName) {
59
61
  return;
60
62
  }
63
+ const logger = getLogger(['initAndroidPushToken']);
61
64
  const setDeviceToken = async (token: string) => {
62
65
  const userId = client.streamClient._user?.id ?? '';
63
66
  if (
64
67
  lastFirebaseToken.token === token &&
65
68
  lastFirebaseToken.userId === userId
66
69
  ) {
67
- getLogger(['initAndroidPushToken'])(
70
+ logger(
68
71
  'debug',
69
72
  `Skipping setting the same token again for userId: ${userId} and token: ${token}`
70
73
  );
@@ -74,33 +77,41 @@ export async function initAndroidPushToken(
74
77
  setPushLogoutCallback(async () => {
75
78
  lastFirebaseToken = { token: '', userId: '' };
76
79
  try {
77
- getLogger(['initAndroidPushToken'])(
78
- 'debug',
79
- `Logout removeDeviceToken: ${token}`
80
- );
80
+ logger('debug', `Logout removeDeviceToken: ${token}`);
81
81
  await client.removeDevice(token);
82
82
  } catch (err) {
83
- const logger = getLogger(['initAndroidPushToken']);
84
83
  logger('warn', 'Failed to remove firebase token from stream', err);
85
84
  }
86
85
  });
87
86
  const push_provider_name = pushConfig.android.pushProviderName;
87
+ logger('debug', `sending token from firebase: ${token}`);
88
88
  await client.addDevice(token, 'firebase', push_provider_name);
89
89
  };
90
90
  if (pushConfig.isExpo) {
91
- const expoNotificationsLib = getExpoNotificationsLib();
92
- const subscription = expoNotificationsLib.addPushTokenListener(
93
- (devicePushToken) => {
94
- setDeviceToken(devicePushToken.data);
95
- }
96
- );
97
- setUnsubscribeListener(() => subscription.remove());
98
- const devicePushToken =
99
- await expoNotificationsLib.getDevicePushTokenAsync();
100
- const token = devicePushToken.data;
101
- await setDeviceToken(token);
102
- } else {
103
- const messaging = getFirebaseMessagingLib();
91
+ const expoNotificationsLib = pushConfig.onTapNonRingingCallNotification
92
+ ? getExpoNotificationsLib()
93
+ : getExpoNotificationsLibNoThrow();
94
+ if (expoNotificationsLib) {
95
+ logger('debug', `setting expo notification token listeners`);
96
+ const subscription = expoNotificationsLib.addPushTokenListener(
97
+ (devicePushToken) => {
98
+ setDeviceToken(devicePushToken.data);
99
+ }
100
+ );
101
+ setUnsubscribeListener(() => subscription.remove());
102
+ const devicePushToken =
103
+ await expoNotificationsLib.getDevicePushTokenAsync();
104
+ const token = devicePushToken.data;
105
+ await setDeviceToken(token);
106
+ }
107
+ }
108
+ // TODO: remove the incomingCallChannel check and find a better way once we have telecom integration for android
109
+ const messaging =
110
+ pushConfig.isExpo && !pushConfig.android.incomingCallChannel
111
+ ? getFirebaseMessagingLibNoThrow(true)
112
+ : getFirebaseMessagingLib();
113
+ if (messaging) {
114
+ logger('debug', `setting firebase token listeners`);
104
115
  const unsubscribe = messaging().onTokenRefresh((refreshedToken) =>
105
116
  setDeviceToken(refreshedToken)
106
117
  );
@@ -246,7 +257,7 @@ export const firebaseDataHandler = async (
246
257
  if (!incomingCallChannel || !incomingCallNotificationTextGetters) {
247
258
  const logger = getLogger(['firebaseMessagingOnMessageHandler']);
248
259
  logger(
249
- 'info',
260
+ 'error',
250
261
  "Can't show incoming call notification as either or both incomingCallChannel and incomingCallNotificationTextGetters were not provided"
251
262
  );
252
263
  return;
@@ -1,5 +1,6 @@
1
1
  export type ExpoNotificationsLib = typeof import('expo-notifications');
2
2
 
3
+ import { getLogger } from '@stream-io/video-client';
3
4
  import type { Notification } from 'expo-notifications';
4
5
 
5
6
  export type ExpoNotification = Notification;
@@ -13,7 +14,17 @@ try {
13
14
  export function getExpoNotificationsLib() {
14
15
  if (!expoNotificationsLib) {
15
16
  throw Error(
16
- 'expo-notifications library is not installed. Please see https://docs.expo.dev/versions/latest/sdk/notifications/ for installation instructions'
17
+ 'expo-notifications library is not installed. Please see https://docs.expo.dev/versions/latest/sdk/notifications/ for installation instructions. It is required for non ringing push notifications.'
18
+ );
19
+ }
20
+ return expoNotificationsLib;
21
+ }
22
+
23
+ export function getExpoNotificationsLibNoThrow() {
24
+ if (!expoNotificationsLib) {
25
+ getLogger(['getExpoNotificationsLibNoThrow'])(
26
+ 'debug',
27
+ 'expo-notifications library is not installed. It is required for non ringing push notifications and not for ringing'
17
28
  );
18
29
  }
19
30
  return expoNotificationsLib;
@@ -21,7 +21,7 @@ export function getFirebaseMessagingLibNoThrow(isExpo: boolean) {
21
21
  if (!lib) {
22
22
  const logger = getLogger(['getFirebaseMessagingLibNoThrow']);
23
23
  logger(
24
- 'warn',
24
+ 'debug',
25
25
  `${
26
26
  isExpo
27
27
  ? 'In Expo, @react-native-firebase/messaging library is required to receive ringing notifications in app killed state for Android.'
@@ -27,6 +27,14 @@ export function setupIosCallKeepEvents(
27
27
  if (Platform.OS !== 'ios' || !pushConfig.ios.pushProviderName) {
28
28
  return;
29
29
  }
30
+ if (!pushConfig.android.incomingCallChannel) {
31
+ // TODO: remove this check and find a better way once we have telecom integration for android
32
+ getLogger(['setupIosCallKeepEvents'])(
33
+ 'debug',
34
+ 'android incomingCallChannel is not defined, so skipping the setupIosCallKeepEvents'
35
+ );
36
+ return;
37
+ }
30
38
  const logger = getLogger(['setupIosCallKeepEvents']);
31
39
  const callkeep = getCallKeepLib();
32
40
 
@@ -13,6 +13,14 @@ export function setupIosVoipPushEvents(
13
13
  return;
14
14
  }
15
15
  const logger = getLogger(['setupIosVoipPushEvents']);
16
+ if (!pushConfig.android.incomingCallChannel) {
17
+ // TODO: remove this check and find a better way once we have telecom integration for android
18
+ logger(
19
+ 'debug',
20
+ 'android incomingCallChannel is not defined, so skipping the setupIosVoipPushEvents'
21
+ );
22
+ return;
23
+ }
16
24
  const voipPushNotification = getVoipPushNotificationLib();
17
25
 
18
26
  logger('debug', 'notification event listener added');
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.10.16';
1
+ export const version = '1.10.17';