fix(notifications): send deviceId on refresh to match backend contract

The /notifications/refresh endpoint now requires deviceId or fcmToken.
Reuse the stable device ID from registration so refresh no longer returns 400.
This commit is contained in:
Jose Olarte III
2026-06-05 19:14:07 +08:00
parent 00abd5277f
commit 55ef36be06

View File

@@ -14,6 +14,7 @@
import { Capacitor } from "@capacitor/core";
import type { PushNotificationSchema } from "@capacitor/push-notifications";
import { DailyNotification } from "@/plugins/DailyNotificationPlugin";
import { getOrCreateDeviceId } from "./deviceId";
import { REMINDER_ID_DAILY_REMINDER } from "./reminderIds";
import { configureNativeFetcherIfReady } from "./nativeFetcherConfig";
import {
@@ -601,11 +602,22 @@ export async function refreshNotificationsWithDiagnostics(options?: {
};
}
let deviceId: string | undefined;
try {
deviceId = await getOrCreateDeviceId();
} catch (err) {
logger.warn(
"[NativeNotificationService] Could not obtain deviceId; refresh proceeding without deviceId",
err,
);
}
const baseUrl = getNotificationApiBaseUrl();
const res = await fetch(`${baseUrl}/notifications/refresh`, {
method: "POST",
headers: auth.headers,
body: JSON.stringify({
deviceId,
platform: Capacitor.getPlatform(),
testMode: getTestMode(),
}),