feat: send FCM token to backend on permission grant
Some checks failed
Build frontend / build (push) Failing after 25s

This commit is contained in:
Claw AI
2026-03-31 20:20:52 +00:00
parent 199e78d6b1
commit 9e87aa90e8

View File

@ -43,6 +43,28 @@ export async function requestNotificationPermission() {
}); });
console.log("[FCM] Token:", token); console.log("[FCM] Token:", token);
// Send token to backend
if (token) {
try {
const authToken = localStorage.getItem("auth_token");
if (authToken) {
const apiBase = process.env.NEXT_PUBLIC_API_URL || "http://45.93.137.91/api";
await fetch(`${apiBase}/Notifications/RegisterWebToken`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${authToken}`,
},
body: JSON.stringify({ token }),
});
console.log("[FCM] Token sent to backend");
}
} catch (err) {
console.error("[FCM] Failed to send token to backend:", err);
}
}
return token; return token;
} catch (err) { } catch (err) {
console.error("[FCM] Error getting token:", err); console.error("[FCM] Error getting token:", err);