fixed push notifications and auth modified
CI/CD / Backend Unit Tests (push) Successful in 2m17s
CI/CD / Deploy (push) Successful in 2m26s

This commit is contained in:
2026-06-11 13:30:36 +02:00
parent 3afe5e2931
commit 7d7e641f5b
8 changed files with 72 additions and 9 deletions
+20
View File
@@ -5,6 +5,7 @@ import {
onTokenRefresh,
AuthorizationStatus,
} from '@react-native-firebase/messaging';
import notifee, { AndroidImportance } from '@notifee/react-native';
import { post } from '@/services/api';
export async function registerDeviceToken(authToken: string): Promise<void> {
@@ -32,4 +33,23 @@ export function listenForTokenRefresh(authToken: string): () => void {
return onTokenRefresh(getMessaging(), async (newToken) => {
await post('/device-tokens/register', { token: newToken }, authToken);
});
}
export async function displayLocalNotification(title?: string, body?: string) {
if (!title && !body) return;
const channelId = await notifee.createChannel({
id: 'default',
name: 'General',
importance: AndroidImportance.HIGH,
});
await notifee.displayNotification({
title,
body,
android: {
channelId,
pressAction: { id: 'default' },
},
});
}