All 3 auth methods work & update public profile table as well

This commit is contained in:
2025-03-10 13:59:04 -05:00
parent 07bf94d393
commit f9fd5dafc5
6 changed files with 140 additions and 83 deletions

View File

@ -13,12 +13,15 @@ Notifications.setNotificationHandler({
}),
});
export const sendPushNotification = async(expoPushToken: string | null, notification: NotificationMessage) => {
export const sendPushNotification = async (
expoPushToken: string | null,
notification: NotificationMessage,
) => {
if (!expoPushToken) {
Alert.alert('Error', 'No push token found.');
return;
}
const message = {
const message = {
to: expoPushToken,
sound: notification.sound ?? 'default',
title: notification.title,
@ -86,18 +89,20 @@ async function registerForPushNotificationsAsync() {
const PushNotificationManager = ({ children }: { children: React.ReactNode }) => {
const [expoPushToken, setExpoPushToken] = useState<string | undefined>('');
const [notification, setNotification] = useState<Notifications.Notification | undefined>(undefined);
const [notification, setNotification] = useState<Notifications.Notification | undefined>(
undefined,
);
const notificationListener = useRef<Notifications.Subscription>();
const responseListener = useRef<Notifications.Subscription>();
useEffect(() => {
registerForPushNotificationsAsync().then(token => setExpoPushToken(token));
registerForPushNotificationsAsync().then((token) => setExpoPushToken(token));
notificationListener.current = Notifications.addNotificationReceivedListener(notification => {
notificationListener.current = Notifications.addNotificationReceivedListener((notification) => {
setNotification(notification);
});
responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
responseListener.current = Notifications.addNotificationResponseReceivedListener((response) => {
console.log(response);
// Handle notification response here
});
@ -109,5 +114,5 @@ const PushNotificationManager = ({ children }: { children: React.ReactNode }) =>
}, []);
return <>{children}</>;
}
};
export default PushNotificationManager;