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:
@@ -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(),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user