as-app/src/notifications/channels/notifBackgroundGeolocationLost.js

55 lines
1.3 KiB
JavaScript

import { createLogger } from "~/lib/logger";
import { BACKGROUND_SCOPES } from "~/lib/logger/scopes";
import { Light } from "~/theme/app";
import { displayNotification } from "../helpers";
import { generateBackgroundGeolocationLostContent } from "../content";
const { colors } = Light;
const backgroundGeolocationLogger = createLogger({
module: BACKGROUND_SCOPES.NOTIFICATIONS,
feature: "background-geolocation-channel",
});
const channelId = "system";
export default async function notifBackgroundGeolocationLost(data) {
backgroundGeolocationLogger.debug(
"Displaying background geolocation lost notification",
{
data,
},
);
// Generate notification content
const { title, body, bigText } =
generateBackgroundGeolocationLostContent(data);
await displayNotification({
channelId,
title,
body,
data,
color: colors.warning || colors.primary,
bigText,
android: {
pressAction: {
id: "open-settings",
launchActivity: "default",
},
actions: [
{
title: "Paramètres",
pressAction: {
id: "open-settings",
launchActivity: "default",
},
},
],
},
});
backgroundGeolocationLogger.info(
"Background geolocation lost notification displayed successfully",
);
}