fix: bg location lost notif
This commit is contained in:
parent
4e2ea42195
commit
2fa7b4839a
8 changed files with 104 additions and 4 deletions
9
src/notifications/actions/actionOpenSettings.js
Normal file
9
src/notifications/actions/actionOpenSettings.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { navActions } from "~/stores";
|
||||
|
||||
export default function actionOpenSettings({ data }) {
|
||||
navActions.setNextNavigation([
|
||||
{
|
||||
name: "Params",
|
||||
},
|
||||
]);
|
||||
}
|
55
src/notifications/channels/notifBackgroundGeolocationLost.js
Normal file
55
src/notifications/channels/notifBackgroundGeolocationLost.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
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",
|
||||
);
|
||||
}
|
10
src/notifications/channels/notifSystem.js
Normal file
10
src/notifications/channels/notifSystem.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { createChannel } from "../helpers";
|
||||
|
||||
const channelId = "system";
|
||||
|
||||
export async function createNotificationChannel() {
|
||||
await createChannel({
|
||||
id: channelId,
|
||||
name: "System",
|
||||
});
|
||||
}
|
|
@ -88,9 +88,9 @@ export const generateSuggestKeepOpenContent = (data) => {
|
|||
|
||||
export const generateBackgroundGeolocationLostContent = (data) => {
|
||||
return {
|
||||
title: `Localisation en arrière-plan désactivée`,
|
||||
body: `Votre localisation en arrière-plan a été désactivée. Veuillez vérifier les paramètres de l'application.`,
|
||||
bigText: `Votre localisation en arrière-plan a été désactivée. Pour continuer à utiliser pleinement l'application, veuillez vérifier les paramètres de votre appareil.`,
|
||||
title: `Alerte-Secours ne peut plus accéder à votre position`,
|
||||
body: `Vous ne pouvez plus recevoir d'alertes de proximité. Vérifiez les paramètres.`,
|
||||
bigText: `Alerte-Secours ne peut plus accéder à votre position en arrière-plan. Vous ne pouvez plus recevoir d'alertes de proximité. Causes possibles : permissions révoquées, optimisation de batterie active, ou actualisation désactivée. Accédez aux paramètres de l'application pour réactiver.`,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import notifSuggestClose from "./channels/notifSuggestClose";
|
|||
import notifSuggestKeepOpen from "./channels/notifSuggestKeepOpen";
|
||||
import notifRelativeAllowAsk from "./channels/notifRelativeAllowAsk";
|
||||
import notifRelativeInvitation from "./channels/notifRelativeInvitation";
|
||||
import notifBackgroundGeolocationLost from "./channels/notifBackgroundGeolocationLost";
|
||||
|
||||
const displayLogger = createLogger({
|
||||
module: BACKGROUND_SCOPES.NOTIFICATIONS,
|
||||
|
@ -20,6 +21,7 @@ const SUPPORTED_ACTIONS = {
|
|||
"suggest-keep-open": notifSuggestKeepOpen,
|
||||
"relative-allow-ask": notifRelativeAllowAsk,
|
||||
"relative-invitation": notifRelativeInvitation,
|
||||
"background-geolocation-lost": notifBackgroundGeolocationLost,
|
||||
};
|
||||
|
||||
export default async function displayNotificationHandler(data) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { VirtualNotificationTypes } from "./virtualNotifications";
|
||||
import { getNotificationContent } from "./content";
|
||||
import openSettings from "~/lib/native/openSettings";
|
||||
import { navActions } from "~/stores";
|
||||
|
||||
export const getNotificationColor = (notification, theme) => {
|
||||
const { colors } = theme;
|
||||
|
@ -83,7 +84,13 @@ export const createNotificationHandlers = (handlers) => {
|
|||
suggest_keep_open: async (data) => await openAlert({ data }),
|
||||
relative_invitation: async (data) => await openRelatives({ data }),
|
||||
relative_allow_ask: async (data) => await openRelatives({ data }),
|
||||
background_geolocation_lost: async (data) => openSettings(),
|
||||
background_geolocation_lost: async (data) => {
|
||||
navActions.setNextNavigation([
|
||||
{
|
||||
name: "Params",
|
||||
},
|
||||
]);
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -14,6 +14,7 @@ import actionRelativeAllowAccept from "./actions/actionRelativeAllowAccept";
|
|||
import actionRelativeAllowReject from "./actions/actionRelativeAllowReject";
|
||||
import actionRelativeInvitationAccept from "./actions/actionRelativeInvitationAccept";
|
||||
import actionRelativeInvitationReject from "./actions/actionRelativeInvitationReject";
|
||||
import actionOpenSettings from "./actions/actionOpenSettings";
|
||||
|
||||
import { navActions } from "~/stores";
|
||||
|
||||
|
@ -273,5 +274,9 @@ export const onEvent = async ({ type, notification, pressAction }) => {
|
|||
await actionRelativeInvitationReject({ data });
|
||||
break;
|
||||
}
|
||||
case "open-settings": {
|
||||
await actionOpenSettings({ data });
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@ import { createNotificationChannel as createSuggestCloseChannel } from "./channe
|
|||
import { createNotificationChannel as createSuggestKeepOpenChannel } from "./channels/notifSuggestKeepOpen";
|
||||
import { createNotificationChannel as createRelativeAllowAskChannel } from "./channels/notifRelativeAllowAsk";
|
||||
import { createNotificationChannel as createRelativeInvitationChannel } from "./channels/notifRelativeInvitation";
|
||||
import { createNotificationChannel as createSystemChannel } from "./channels/notifSystem";
|
||||
|
||||
export default async function setActionCategories() {
|
||||
// Create all notification channels
|
||||
|
@ -17,6 +18,7 @@ export default async function setActionCategories() {
|
|||
createSuggestKeepOpenChannel(),
|
||||
createRelativeAllowAskChannel(),
|
||||
createRelativeInvitationChannel(),
|
||||
createSystemChannel(),
|
||||
]);
|
||||
} catch (error) {
|
||||
const errorData = {
|
||||
|
@ -113,5 +115,15 @@ export default async function setActionCategories() {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "system",
|
||||
actions: [
|
||||
{
|
||||
id: "open-settings",
|
||||
title: "Paramètres",
|
||||
foreground: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue