Skip to content
Open
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
44 changes: 43 additions & 1 deletion guard_app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,52 @@
// App.tsx
import { NavigationContainer } from '@react-navigation/native';
import React from 'react';
import * as Notifications from 'expo-notifications';
import React, { useEffect } from 'react';
import { Platform, Alert } from 'react-native';

import AppNavigator from './src/navigation/AppNavigator';

Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: false,
}),
});

export default function App() {
useEffect(() => {
// Android Channel Setup
if (Platform.OS === 'android') {
Notifications.setNotificationChannelAsync('default', {
name: 'default',
importance: Notifications.AndroidImportance.MAX,
vibrationPattern: [0, 250, 250, 250],
lightColor: '#FF231F7C',
});
}

const foregroundSubscription = Notifications.addNotificationReceivedListener(notification => {

Check failure on line 29 in guard_app/App.tsx

View workflow job for this annotation

GitHub Actions / ESLint & Prettier

Replace `notification` with `(notification)`
console.log('Foreground notification:', notification);

Check warning on line 30 in guard_app/App.tsx

View workflow job for this annotation

GitHub Actions / ESLint & Prettier

Unexpected console statement
});

const responseSubscription = Notifications.addNotificationResponseReceivedListener(response => {

Check failure on line 33 in guard_app/App.tsx

View workflow job for this annotation

GitHub Actions / ESLint & Prettier

Replace `response` with `⏎······(response)`
const { title } = response.notification.request.content;

Check failure on line 34 in guard_app/App.tsx

View workflow job for this annotation

GitHub Actions / ESLint & Prettier

Insert `··`
const data = response.notification.request.content.data;

Check failure on line 35 in guard_app/App.tsx

View workflow job for this annotation

GitHub Actions / ESLint & Prettier

Replace `······` with `········`

console.log('Notification tapped:', title);

Check warning on line 37 in guard_app/App.tsx

View workflow job for this annotation

GitHub Actions / ESLint & Prettier

Unexpected console statement

Check failure on line 37 in guard_app/App.tsx

View workflow job for this annotation

GitHub Actions / ESLint & Prettier

Insert `··`

if (data.screen === 'Shifts') {

Check failure on line 39 in guard_app/App.tsx

View workflow job for this annotation

GitHub Actions / ESLint & Prettier

Replace `······` with `········`
Alert.alert("Notification Tapped", `Redirecting to ${title}`);

Check failure on line 40 in guard_app/App.tsx

View workflow job for this annotation

GitHub Actions / ESLint & Prettier

Replace `Alert.alert("Notification·Tapped"` with `··Alert.alert('Notification·Tapped'`
}

Check failure on line 41 in guard_app/App.tsx

View workflow job for this annotation

GitHub Actions / ESLint & Prettier

Insert `··`
});

Check failure on line 42 in guard_app/App.tsx

View workflow job for this annotation

GitHub Actions / ESLint & Prettier

Replace `}` with `··},⏎····`

return () => {
foregroundSubscription.remove();
responseSubscription.remove();
};
}, []);

return (
<NavigationContainer>
<AppNavigator />
Expand Down
Loading
Loading