feat(android/ios): Native API events for show/hide notification (#15577)

Added show/hide notification events for native Android/iOS
This commit is contained in:
Calinteodor
2025-02-10 11:34:50 +02:00
committed by GitHub
parent 7262465777
commit f670f39dd2
9 changed files with 100 additions and 12 deletions

View File

@@ -51,6 +51,8 @@ import { getLocalTracks, isLocalTrackMuted } from '../../base/tracks/functions.n
import { ITrack } from '../../base/tracks/types';
import { CLOSE_CHAT, OPEN_CHAT } from '../../chat/actionTypes';
import { closeChat, openChat, sendMessage, setPrivateMessageRecipient } from '../../chat/actions.native';
import { hideNotification, showNotification } from '../../notifications/actions';
import { NOTIFICATION_TIMEOUT_TYPE, NOTIFICATION_TYPE } from '../../notifications/constants';
import { setRequestingSubtitles } from '../../subtitles/actions.any';
import { CUSTOM_BUTTON_PRESSED } from '../../toolbox/actionTypes';
import { muteLocal } from '../../video-menu/actions.native';
@@ -419,6 +421,35 @@ function _registerForNativeEvents(store: IStore) {
eventEmitter.addListener(ExternalAPI.TOGGLE_CAMERA, () => {
dispatch(toggleCameraFacingMode());
});
eventEmitter.addListener(ExternalAPI.SHOW_NOTIFICATION,
({ appearance, description, timeout, title, uid }: any) => {
const validTypes = Object.values(NOTIFICATION_TYPE);
const validTimeouts = Object.values(NOTIFICATION_TIMEOUT_TYPE);
if (!validTypes.includes(appearance)) {
logger.error(`Invalid notification type "${appearance}". Expecting one of ${validTypes}`);
return;
}
if (!validTimeouts.includes(timeout)) {
logger.error(`Invalid notification timeout "${timeout}". Expecting one of ${validTimeouts}`);
return;
}
dispatch(showNotification({
appearance,
description,
title,
uid
}, timeout));
});
eventEmitter.addListener(ExternalAPI.HIDE_NOTIFICATION, ({ uid }: any) => {
dispatch(hideNotification(uid));
});
}
/**
@@ -439,6 +470,8 @@ function _unregisterForNativeEvents() {
eventEmitter.removeAllListeners(ExternalAPI.SEND_CHAT_MESSAGE);
eventEmitter.removeAllListeners(ExternalAPI.SET_CLOSED_CAPTIONS_ENABLED);
eventEmitter.removeAllListeners(ExternalAPI.TOGGLE_CAMERA);
eventEmitter.removeAllListeners(ExternalAPI.SHOW_NOTIFICATION);
eventEmitter.removeAllListeners(ExternalAPI.HIDE_NOTIFICATION);
}
/**