diff --git a/firebase-messaging-sw.js b/firebase-messaging-sw.js new file mode 100644 index 00000000..6c7d689a --- /dev/null +++ b/firebase-messaging-sw.js @@ -0,0 +1,18 @@ +import { getMessaging, getToken } from "firebase/messaging"; + +// Get registration token. Initially this makes a network call, once retrieved +// subsequent calls to getToken will return from cache. +const messaging = getMessaging(); +getToken(messaging, { vapidKey: '' }).then((currentToken) => { + if (currentToken) { + // Send the token to your server and update the UI if necessary + // ... + } else { + // Show permission request UI + console.log('No registration token available. Request permission to generate one.'); + // ... + } +}).catch((err) => { + console.log('An error occurred while retrieving token. ', err); + // ... +}); diff --git a/src/firebase/index.js b/src/firebase/index.js index 39d7bc09..50d39249 100644 --- a/src/firebase/index.js +++ b/src/firebase/index.js @@ -1,7 +1,9 @@ // Import the functions you need from the SDKs you need import { initializeApp } from 'firebase/app'; +import { getMessaging } from "firebase/messaging"; import { getAuth } from 'firebase/auth'; import { getFirestore } from 'firebase/firestore'; +import { doc, setDoc } from "firebase/firestore"; // TODO: Add SDKs for Firebase products that you want to use // https://firebase.google.com/docs/web/setup#available-libraries @@ -31,8 +33,10 @@ const firebaseConfig = { // https://firebase.google.com/docs/web/setup // https://docs.expo.dev/guides/using-firebase/ const app = initializeApp(firebaseConfig); - +const messaging = getMessaging(app); +messaging.getToken({vapidKey:"BDGGnJytH87x6d886c7RfRvftpPViuXWxHb4ev9rGP72YuvmvuXCJ7XxaPDsFo9_IX7JlTGSvByeifflY6DOpHM"}); const auth = getAuth(); const db = getFirestore(app); -export { auth, db }; + +export { auth, db, }; diff --git a/src/navigation/AppNavigator.js b/src/navigation/AppNavigator.js index 424828be..7e8dd782 100644 --- a/src/navigation/AppNavigator.js +++ b/src/navigation/AppNavigator.js @@ -11,6 +11,7 @@ import { AuthScreen, LoginScreen, HomeScreen, + GroupLinkScreen, } from '../screens'; const Stack = createNativeStackNavigator(); @@ -51,6 +52,11 @@ const AppNavigator = () => { options={{ headerTitle: 'Supper Snacks' }} component={AuthScreen} /> + ); diff --git a/src/screens/GroupLinkScreen.js b/src/screens/GroupLinkScreen.js new file mode 100644 index 00000000..fc654c31 --- /dev/null +++ b/src/screens/GroupLinkScreen.js @@ -0,0 +1,38 @@ +import { StyleSheet, View, Pressable, Text } from 'react-native'; +import React from 'react'; + +const MainScreen = ({ navigation }) => { + return ( + + navigation.navigate('Auth')} + android_ripple={{ color: '#FFF' }} + > + Supper Snacks + + + ); +}; + +export default GroupLinkScreen; + +const styles = StyleSheet.create({ + container: { + backgroundColor: '#EBECF0', + flex: 1, + justifyContent: 'center', + alignItems: 'center', + }, + button: { + backgroundColor: '#407BFF', + marginVertical: 10, + paddingVertical: 10, + width: '80%', + alignItems: 'center', + borderRadius: 4, + }, + text: { + color: 'white', + }, +}); \ No newline at end of file diff --git a/src/screens/HomeScreen.js b/src/screens/HomeScreen.js index 2a0c8e0a..635d5602 100644 --- a/src/screens/HomeScreen.js +++ b/src/screens/HomeScreen.js @@ -22,7 +22,7 @@ const THEME = '#407BFF'; const { width } = Dimensions.get('window'); -const HomeScreen = () => { +const HomeScreen = ({navigation}) => { const [task, setTask] = useState(''); const [taskList, setTaskList] = useState([]); /* @@ -92,7 +92,6 @@ const HomeScreen = () => { > - Your Orders 🍔 Choose Your Group { showsVerticalScrollIndicator={false} /> Halls navigation.navigate('Group')} style={styles.button} > Residential Colleges + + Residences +