fix(ios): executeHeartbeatSync with silent push notification

This commit is contained in:
Jo 2025-07-23 14:28:00 +02:00
parent 5461852ada
commit 38e2f821dd
Signed by: devthejo
GPG key ID: 00CCA7A92B1D5351
2 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,38 @@
import { createLogger } from "~/lib/logger";
import { BACKGROUND_SCOPES } from "~/lib/logger/scopes";
import { executeHeartbeatSync } from "~/location/backgroundTask";
const heartbeatLogger = createLogger({
module: BACKGROUND_SCOPES.NOTIFICATIONS,
feature: "geolocation-heartbeat-sync",
});
export default async function notifGeolocationHeartbeatSync(data) {
try {
heartbeatLogger.info(
"Received iOS geolocation heartbeat sync notification",
{
data,
},
);
// This is a silent notification - no visible notification is displayed
// Instead, we trigger the geolocation heartbeat sync directly
heartbeatLogger.info("Triggering geolocation heartbeat sync");
// Execute the heartbeat sync to force location update
await executeHeartbeatSync();
heartbeatLogger.info("Geolocation heartbeat sync completed successfully");
} catch (error) {
heartbeatLogger.error("Failed to execute geolocation heartbeat sync", {
error: error.message,
stack: error.stack,
data,
});
// Don't throw the error - this is a background operation
// and we don't want to crash the notification handler
}
}

View file

@ -8,6 +8,7 @@ import notifSuggestKeepOpen from "./channels/notifSuggestKeepOpen";
import notifRelativeAllowAsk from "./channels/notifRelativeAllowAsk";
import notifRelativeInvitation from "./channels/notifRelativeInvitation";
import notifBackgroundGeolocationLost from "./channels/notifBackgroundGeolocationLost";
import notifGeolocationHeartbeatSync from "./channels/notifGeolocationHeartbeatSync";
const displayLogger = createLogger({
module: BACKGROUND_SCOPES.NOTIFICATIONS,
@ -22,6 +23,7 @@ const SUPPORTED_ACTIONS = {
"relative-allow-ask": notifRelativeAllowAsk,
"relative-invitation": notifRelativeInvitation,
"background-geolocation-lost": notifBackgroundGeolocationLost,
"geolocation-heartbeat-sync": notifGeolocationHeartbeatSync,
};
export default async function displayNotificationHandler(data) {