Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ import {
} from 'react-native';
import { CallingState, videoLoggerSystem } from '@stream-io/video-client';
import { keepCallAliveCallRef } from '../utils/keepCallAliveHeadlessTask';
import { getNotifeeLibNoThrowForKeepCallAlive } from '../utils/push/libs/notifee';
import { getCallingxLibIfAvailable } from '../utils/push/libs';

const notifeeLib = getNotifeeLibNoThrowForKeepCallAlive();

async function stopForegroundServiceNoThrow() {
const logger = videoLoggerSystem.getLogger('stopForegroundServiceNoThrow');
try {
Expand Down Expand Up @@ -119,21 +116,6 @@ export const useAndroidKeepCallAliveEffect = () => {
if (foregroundServiceStartedRef.current) {
return;
}
// Optional compatibility cleanup: if the app uses Notifee for ringing push,
// we might have an incoming call notification running as a foreground service.
if (notifeeLib) {
const notifee = notifeeLib.default;
const displayedNotifications =
await notifee.getDisplayedNotifications();
const activeCallNotification = displayedNotifications.find(
(notification) => notification.id === activeCallCid,
);
if (activeCallNotification) {
// this means that we have a incoming call notification shown as foreground service and we must stop it
notifee.stopForegroundService();
notifee.cancelDisplayedNotification(activeCallCid);
}
}

await startForegroundService(activeCallCid);
foregroundServiceStartedRef.current = true;
Expand All @@ -155,14 +137,6 @@ export const useAndroidKeepCallAliveEffect = () => {
return () => {
sub.remove();
};
} else if (callingState === CallingState.RINGING) {
return () => {
// cancel any notifee displayed notification when the call has transitioned out of ringing
// NOTE: cancels only the non fg service notifications
if (notifeeLib) {
notifeeLib.default.cancelDisplayedNotification(activeCallCid);
}
};
} else if (
callingState === CallingState.IDLE ||
callingState === CallingState.LEFT
Expand All @@ -172,20 +146,6 @@ export const useAndroidKeepCallAliveEffect = () => {
// stop foreground service when the call is not active
stopForegroundServiceNoThrow();
foregroundServiceStartedRef.current = false;
} else {
if (notifeeLib) {
notifeeLib.default
.getDisplayedNotifications()
.then((displayedNotifications) => {
const activeCallNotification = displayedNotifications.find(
(notification) => notification.id === activeCallCid,
);
if (activeCallNotification) {
// this means that we have a incoming call notification shown as foreground service and we must stop it
notifeeLib.default.stopForegroundService();
}
});
}
}
}
return undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-sdk/src/utils/StreamVideoRN/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class StreamVideoRN {
callingx.setup(options);
} catch {
throw new Error(
'react-native-callingx library is not installed. Please check the installation instructions: https://getstream.io/video/docs/react-native/incoming-calls/ringing-setup/react-native/.',
'react-native-callingx library is not installed. Please check our migration instructions: https://getstream.io/video/docs/react-native/migration-guides/1.32.0/.',
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export function getNotifeeLibThrowIfNotInstalledForPush() {
return lib;
}

export function getNotifeeLibNoThrowForKeepCallAlive() {
return lib;
}

export function getIncomingCallForegroundServiceTypes() {
const types: AndroidForegroundServiceType[] = [
AndroidForegroundServiceType.FOREGROUND_SERVICE_TYPE_SHORT_SERVICE,
Expand Down
Loading