App entry — index.js
index.js runs before any UI — also when a push or a VoIP call launches the app in the background. Everything that must exist once per app goes here, before AppRegistry.registerComponent.
Host without its own push handlers:
javascriptindex.js
// index.jsimport {AppRegistry} from 'react-native';import { configurePushNotifications, registerRealtimexBackgroundHandler,} from '@realtimexsco/live-chat-react-native';import App from './src/App';import {name as appName} from './app.json'; // 1. Calling: register VideoSDK once, before any meeting UI.try { require('@videosdk.live/react-native-sdk').register();} catch { // calling peers not installed} // 2. Push options. On iOS this also attaches the CallKit / PushKit listeners,// so a call that launched the app is answered or declined before any UI.configurePushNotifications({ androidFullScreenCalls: true, // with @notifee/react-native onNotificationOpened: target => { // bring your chat tab forward; the package opens the room itself },}); // 3. FCM background handler + Notifee background events.registerRealtimexBackgroundHandler(); AppRegistry.registerComponent(appName, () => App);Host with its own handlers (FCM's background handler and Notifee's background event handler can each be set only once per app — give RealtimeX events to the package first). This is Fieldr's index.js:
javascriptindex.js
// index.js (Fieldr)import notifee, {EventType} from '@notifee/react-native';import messaging from '@react-native-firebase/messaging';import { configurePushNotifications, handleRealtimexBackgroundMessage, handleRealtimexNotifeeEvent,} from '@realtimexsco/live-chat-react-native';import {AppRegistry} from 'react-native';import 'react-native-gesture-handler';import {enableScreens} from 'react-native-screens';import {name as appName} from './app.json';import App from './src/App';import { queueOrHandlePushNotificationPress, queueOrOpenChatTab,} from './src/screens/notification/pushNotificationNavigation'; try { const {register} = require('@videosdk.live/react-native-sdk'); register();} catch {} enableScreens(); configurePushNotifications({ androidFullScreenCalls: true, foregroundSystemNotifications: true, onNotificationOpened: target => { if (target.type !== 'call') { queueOrOpenChatTab(); } },}); messaging().setBackgroundMessageHandler(async message => { await handleRealtimexBackgroundMessage(message);}); notifee.onBackgroundEvent(async event => { if (await handleRealtimexNotifeeEvent(event)) { return; // RealtimeX notification — handled by the package } if (event.type === EventType.PRESS) { queueOrHandlePushNotificationPress({ data: event.detail.notification?.data, title: event.detail.notification?.title, body: event.detail.notification?.body, }); }}); AppRegistry.registerComponent(appName, () => App);All configurePushNotifications options: Push notifications.