-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathApp.tsx
More file actions
68 lines (58 loc) · 2.04 KB
/
App.tsx
File metadata and controls
68 lines (58 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React, { useEffect } from 'react';
import { StatusBar } from 'expo-status-bar';
import { LogBox } from 'react-native';
import AppNavigator from './src/navigation/AppNavigator';
import { useAppStore } from './src/store';
import socketService from './src/services/socket';
import { ErrorBoundary } from './src/components/common/ErrorBoundary';
import "./global.css";
// Notification imports
import { setupNotificationNavigation } from './src/navigation/linking';
import { handleNotificationReceived } from './src/utils/notificationHandlers';
import {
addNotificationReceivedListener,
getLastNotificationResponse,
removeNotificationListener,
} from './src/services/pushNotifications';
// Enable error logging to console (visible in Metro bundler)
if (__DEV__) {
// Log all errors to console
const originalError = console.error;
console.error = (...args) => {
originalError(...args);
// Errors will appear in Metro bundler terminal
};
// Show warnings in console but don't break the app
LogBox.ignoreLogs([
'Non-serializable values were found in the navigation state',
]);
}
export default function App() {
const theme = useAppStore((state) => state.theme);
useEffect(() => {
// Connect to socket when app starts
socketService.connect();
// Set up notification navigation handler
const notificationCleanup = setupNotificationNavigation();
// Listen for notifications received while app is foregrounded
const subscription = addNotificationReceivedListener(handleNotificationReceived);
// Check if app was launched from a notification
getLastNotificationResponse().then((response) => {
if (response) {
console.log('App launched from notification:', response);
}
});
// Cleanup on unmount
return () => {
socketService.disconnect();
notificationCleanup();
removeNotificationListener(subscription);
};
}, []);
return (
<ErrorBoundary>
<StatusBar style={theme === 'dark' ? 'light' : 'dark'} />
<AppNavigator />
</ErrorBoundary>
);
}