All 3 auth methods work & update public profile table as well
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user