From 4ef53e93783f43800fd31ff9d69a30e781d0f114 Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Mon, 25 Aug 2025 10:19:22 -0400 Subject: [PATCH] remove app --- app.json | 11 +---------- app/register.jsx | 32 ++++++++++++++++++++++++++++++-- contexts/firebase.js | 9 ++++----- package-lock.json | 36 ------------------------------------ package.json | 2 -- 5 files changed, 35 insertions(+), 55 deletions(-) diff --git a/app.json b/app.json index 6393487..23d4179 100644 --- a/app.json +++ b/app.json @@ -34,16 +34,7 @@ "plugins": [ "expo-router", "expo-font", - "expo-web-browser", - "@react-native-firebase/app", - [ - "expo-build-properties", - { - "ios": { - "useFrameworks": "static" - } - } - ] + "expo-web-browser" ], "experiments": { "typedRoutes": true diff --git a/app/register.jsx b/app/register.jsx index f4780d1..2109b38 100644 --- a/app/register.jsx +++ b/app/register.jsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import messaging from '@react-native-firebase/messaging'; +import * as Notifications from 'expo-notifications'; import { router } from 'expo-router'; import { createUserWithEmailAndPassword, updateProfile } from 'firebase/auth'; import { auth } from '@/contexts/firebase'; @@ -52,7 +52,35 @@ export default function Register() { await updateProfile(userCredential.user, { displayName: `${values.firstName} ${values.lastName}` }); - const token = await messaging().getToken(); + // Request permissions and get push token (native FCM if possible, else Expo token) + let token = null; + let tokenType = null; + const { status: existingStatus } = await Notifications.getPermissionsAsync(); + let finalStatus = existingStatus; + if (existingStatus !== 'granted') { + const { status } = await Notifications.requestPermissionsAsync(); + finalStatus = status; + } + if (finalStatus === 'granted') { + try { + // Try to get native FCM token (works in dev/prod builds, not Expo Go) + const deviceToken = await Notifications.getDevicePushTokenAsync({ provider: 'fcm' }); + if (deviceToken?.data) { + token = deviceToken.data; + tokenType = 'fcm'; + } else { + // Fallback to Expo push token + const expoToken = await Notifications.getExpoPushTokenAsync(); + token = expoToken.data; + tokenType = 'expo'; + } + } catch (e) { + // Fallback to Expo push token if native fails + const expoToken = await Notifications.getExpoPushTokenAsync(); + token = expoToken.data; + tokenType = 'expo'; + } + } await postgresServices.createUser({ firstName: values.firstName, diff --git a/contexts/firebase.js b/contexts/firebase.js index 8a593f2..bfd2449 100644 --- a/contexts/firebase.js +++ b/contexts/firebase.js @@ -1,6 +1,6 @@ + import { initializeApp } from 'firebase/app'; -import { initializeAuth, getReactNativePersistence } from 'firebase/auth'; -import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage'; +import { getAuth } from 'firebase/auth'; const firebaseConfig = { apiKey: process.env.EXPO_PUBLIC_FIREBASE_API_KEY, @@ -12,9 +12,8 @@ const firebaseConfig = { appId: process.env.EXPO_PUBLIC_FIREBASE_APP_ID, }; + const app = initializeApp(firebaseConfig); -const auth = initializeAuth(app, { - persistence: getReactNativePersistence(ReactNativeAsyncStorage) -}); +const auth = getAuth(app); export { auth }; diff --git a/package-lock.json b/package-lock.json index 357588b..f3739e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,6 @@ "@emotion/unitless": "^0.10.0", "@expo/vector-icons": "^14.0.2", "@react-native-async-storage/async-storage": "^1.24.0", - "@react-native-firebase/app": "^23.1.1", - "@react-native-firebase/messaging": "^23.1.1", "@react-native-picker/picker": "^2.11.1", "@react-navigation/native": "^7.1.17", "expo": "^53.0.20", @@ -3118,40 +3116,6 @@ "react-native": "^0.0.0-0 || >=0.60 <1.0" } }, - "node_modules/@react-native-firebase/app": { - "version": "23.1.1", - "resolved": "https://registry.npmjs.org/@react-native-firebase/app/-/app-23.1.1.tgz", - "integrity": "sha512-w6fSGukDPzHiDbF3d8g1MYrlcoHtAn0pezUDYcmhZjDMldPBb5yxDi8/tj96K+0AecY6nCbOh5VgwY0bEd3iOQ==", - "license": "Apache-2.0", - "dependencies": { - "firebase": "12.1.0" - }, - "peerDependencies": { - "expo": ">=47.0.0", - "react": "*", - "react-native": "*" - }, - "peerDependenciesMeta": { - "expo": { - "optional": true - } - } - }, - "node_modules/@react-native-firebase/messaging": { - "version": "23.1.1", - "resolved": "https://registry.npmjs.org/@react-native-firebase/messaging/-/messaging-23.1.1.tgz", - "integrity": "sha512-P6jH3jGGXIDn+EuCognMWkegqR/cDmEAMXHLV+XgodCSMoMODBfswJWmKYoX/7xkjBsptOXUKI6uwo3S+H5z1Q==", - "license": "Apache-2.0", - "peerDependencies": { - "@react-native-firebase/app": "23.1.1", - "expo": ">=47.0.0" - }, - "peerDependenciesMeta": { - "expo": { - "optional": true - } - } - }, "node_modules/@react-native-picker/picker": { "version": "2.11.1", "resolved": "https://registry.npmjs.org/@react-native-picker/picker/-/picker-2.11.1.tgz", diff --git a/package.json b/package.json index 1da7de5..63baa32 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,6 @@ "@emotion/unitless": "^0.10.0", "@expo/vector-icons": "^14.0.2", "@react-native-async-storage/async-storage": "^1.24.0", - "@react-native-firebase/app": "^23.1.1", - "@react-native-firebase/messaging": "^23.1.1", "@react-native-picker/picker": "^2.11.1", "@react-navigation/native": "^7.1.17", "expo": "^53.0.20",