fix(ios): executeHeartbeatSync with silent push notification
This commit is contained in:
parent
5461852ada
commit
38e2f821dd
2 changed files with 40 additions and 0 deletions
38
src/notifications/channels/notifGeolocationHeartbeatSync.js
Normal file
38
src/notifications/channels/notifGeolocationHeartbeatSync.js
Normal 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
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue