5f12b2857d
- Foreground notification handler in App.tsx (iOS shows banners while active) - requestNotificationPermissions() called on app mount - GPS task tracks running distance per recording session (module-level state) - Fires immediate notification at each km crossed, gated on kmNotifications setting
30 lines
875 B
TypeScript
30 lines
875 B
TypeScript
import { useEffect } from 'react';
|
|
import { StatusBar } from 'expo-status-bar';
|
|
import * as Notifications from 'expo-notifications';
|
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
import { AppNavigator } from './src/navigation/AppNavigator';
|
|
import { requestNotificationPermissions } from './src/services/gps';
|
|
|
|
// Show notifications even when the app is in the foreground (iOS suppresses by default)
|
|
Notifications.setNotificationHandler({
|
|
handleNotification: async () => ({
|
|
shouldShowBanner: true,
|
|
shouldShowList: true,
|
|
shouldPlaySound: true,
|
|
shouldSetBadge: false,
|
|
}),
|
|
});
|
|
|
|
export default function App() {
|
|
useEffect(() => {
|
|
requestNotificationPermissions();
|
|
}, []);
|
|
|
|
return (
|
|
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
<StatusBar style="light" />
|
|
<AppNavigator />
|
|
</GestureHandlerRootView>
|
|
);
|
|
}
|